When you compare their stats, when Shedinja evolves from Nincada, it loses 30 HP and 45 Defense, but gains 45 Attack. The Special (Attack and Defense) and Speed stats remain the same.
31--->01 (-30)
45--->90 (+45)
90--->45 (-45)
30--->30
30--->30
40--->40
266->236 (-30)
So, it's all because of the loss of HP, since the loss of Defense and gain of Attack counteract each other.