Moshe stripped Aharon of the garments of the Kohen Gadol and dressed Elazar in them inside the cave (Numbers 20:28), as G-d had commanded him to do, thus inaugurating Elazar as the Kohen Gadol. As a Kohen Gadol is forbidden to become ritually impure even upon the death of his immediate relatives, how was Elozar permitted to remain in the cave in which Aharon died, thus rendering Elazar impure?
Rav Aharon Leib Shteinman (Ayeles HaShachar) notes that Baal HaTurim seems to imply that Elazar didn't become the Kohen Gadol until after he was anointed, in which case he was permitted to be present at Aharon's death. S'fas Emes (Kerisos 5) maintains that Elazar did not need an additional anointing since he had already been anointed during the seven days of the consecration of the Mishkan. However, Nachmanides explains (19:2) that contact with those who died through a Divine "kiss" doesn't cause impurity. Since Aharon died in this manner, Elazar could be present even if he was already the Kohen Gadol.