[After the death of the two sons of Aaron (Lev. 16:1).] All four were fit to die, but Moses prayed for them, and his prayer accomplished half. When? At the time when Israel made the calf. What is written there? "And the LORD was very angry with Aaron, to destroy him" (Deut. 9:20). And "destruction" is nothing other than annihilation, as it is said, "And I destroyed his fruit from above" (Amos 2:9). Once Moses prayed, his prayer accomplished half.
Why Moses Prayer Saved Only Half of Aaron's Sons
Midrash Tanchuma Buber, Achrei Mot 12:1
[אחרי מות שני בני אהרן]. ארבעתן היו ראויין למות ונתפלל משה עליהן ועשתה תפלתו מחצה, אימתי בשעה שעשו ישראל את העגל, מה כתיב שם, ובאהרן התאנף ה' מאד להשמידו (דברים ט כ). ואין השמדה אלא כליה, שנאמר ואשמיד פריו ממעל (עמוס ב ט), כיון שנתפלל משה עשה תפלתו מחצה.