As it would have been improper if Aaron had been buried quite naked, God brought about the miracle that, as soon as Moses took off one of Aaron's garments, a corresponding celestial garment was spread over Aaron, and when Moses had stripped him of all his priestly garments, he found himself arrayed in eight celestial garments. A second miracle came to pass in the stripping of Aaron's garments, for Moses was enabled to take off the undermost garments before the upper. This was done in order to satisfy the law that priests may never use their upper garments as undergarments, a thing Eleazar would have had to do, had Moses stripped off Aaron's outer garments first and with these invested his son.
Moses Miraculously Undresses Aaron on Mount Hor
Legends of the Jews 5:67