What's the source of this law? And why is it so?
There are different hadiths about this law. For example:
إنّ الامام لایغسله الا الامام
The Imam is not Qusled unless with Imam.
Reference: Usul Kafi, vol 1, page 384
Qusl means religious washing before burial. Also Prophet Muhammad SAWW was both Imam and messenger at the same time.
Also there are 7 hadith in the Hadith collection book Bihar ul Anwar, vol 27, page 288 says this.
This law happened true about all of the fourteen infallibles in past (only Imam Mahdi a.s. is not dead still and he will be included to this law also. Imam Hussain a.s. will become alive again (رجعت) and will do the Qusl of Imam Mahdi a.s.)