Hashem became very angry with Aharon to destroy him, so I prayed also for Aharon at that time.
Be’er Yosef: Rashi understands the term “to destroy him” in the sense of wiping out his progeny. All of Aharon’s sons were put at risk for the sin of the Golden Calf. Moshe’s prayer was only partially effective. Two sons died; two were spared. R Eliyahu Mizrachi (the Re’em), the great explicator of Rashi, has a hard time harmonizing this view with a different one cited by Rashi at the end of Mishpatim. While Rashi here is rather straightforward about Nadav and Avihu dying as punishment to Aharon for his role in the eigel, Rashi there has Nadav and Avihu deserving to die for inappropriate behavior at the giving of the Torah at Sinai. We must conclude, says the Re’em, that both sins contributed to the handing down of a Heavenly death sentence against them.
We could offer a different explanation. Our attempts at justice are always incomplete. They can never take into account all that Hashem can. When we find a person guilty of a capital crime, we execute him. We do not – we cannot – take into account the pain and sorrow this will cause his family and friends who may be entirely free of any and all sin. HKBH, on the other hand, most definitely weighs all factors before punishing anyone, including the consequences of the death of the guilty on those he leaves behind. (This is what is meant by, “The judgments of Hashem are true, righteous together.” Those judgments are righteous not only to the one who is being judged, but to all people together, i.e. those who are impacted when a sentence in implemented.)
This, then, is what happened to Nadav and Avihu. They were judged to be guilty by Hashem’s court at the time of the giving of the Torah. Aharon, at the time, was guiltless and did not deserve the agony of having children snatched away from him. Nadav and Avihu were not stricken dead at the time. Once Aharon played a central role in the tragic episode of the eigel, his sorrow over the potential loss of two children was no longer sufficient cause to block their punishment. The suspended sentence could be implemented – and was, at the first opportunity they provided through their misstep at the inauguration of the mishkan.
Our pasuk clearly finds fault with Aharon for his role in the eigel. How do we then understand the position of the gemara that finds Aharon’s behavior not only beyond cavil, but even heroic? Having witnessed the death of Chur who protested the actions of the crowd, Aharon feared that he would be the next victim if he tried to prevent the manufacture of the eigel. He worried not so much for his own life, but for the stain on the record of the people if in one day they “killed in Hashem’s mikdash prophet and priest.” Instead, he sacrificed his spiritual well-being in the interests of the people, seemingly going along with the construction plan. In fact, his intention was simply to buy time through stalling as much as he could, expecting Moshe’s imminent return.
We see in this another difference between Divine and human justice. Human courts make binary decisions: innocent/ guilty, good/ bad, exempt/ liable. Hashem, however, can balance many variables at one “moment” of time. His judgment is more nuanced and textured. From one action, He can tease apart strands of good and strands of bad, and address each one separately. Neither need prevail. He rewards the good, and punishes the bad.
Often, the two reside together. This was the case in regard to Aharon’s role in the eigel. He displayed self-sacrifice for the benefit of the nation. He acted with ingenuity – first stalling, then calling for a holiday dedicated to Hashem, rather than the eigel. For all this he was rewarded. But Hashem’s justice does not overlook anything, large or small, neither good nor bad. Aharon did play a role in the readying of a national disaster that eventually involved the idolatrous service of thousands of Jews. For this, Aharon was held accountable. 
We find this principle applied in several other areas. Chazal’s treatment of Lot’s daughters seems inconsistent – until you apply this thinking. One passage speaks of the righteous souls that would emerge from each of the two peoples that were founded incestuously by the two women consorting with their father. The gemara observes that these paragons of virtue did not appear at the same time, but were separated by a large passage of time. Because the older daughter was the first to jump at the “mitzvah” of securing the continuity of civilization by conceiving a child – even if incestuously – a righteous soul emerged from the line of her descendents four generations before a tzadeikes was born to her sister’s family. On the other hand, elsewhere the older daughter is faulted for having been the first, and punished by a less-delicate memorializing of the event relative to her sibling. (The nation of the older daughter is Moav, which directly points to her having a child through her own father; the younger daughter’s nation is Amon, which disguises the fact.)
Following our approach, we can say that her intentions were proper in saving the human race (in her mind) from complete annihilation. Yet, the incident impacted negatively on the morals and mores of the time, which had previously included strong social barriers against gilui arayos. She is praised for the good, while still held accountable for the bad.
Similarly, we find that Dovid HaMelech was punished for saying that “Your statutes to me are as zemiros/ songs.” Chazal apparently object to trivializing Torah by using as light-hearted a term as “songs.” Torah represents the Wisdom of HKBH, and cannot be equated with entertainment. Yet, the very same gemara praises Dovid for constantly finding delight in Torah – even at times of adversity – as shown by his referring to them as songs!
We can use the same approach to resolve the conflict. Dovid’s passion and delight for Torah were praiseworthy. He still may have been punished, however, for failing to modify the expression. Rather than refer to Torah directly as songs, he could perhaps have said, “With song, in song, I delved into Your Torah.”
 Based on Be’er Yosef, Devarim 9:20
 Shemos 24:11
 In Vayikra 10:12 Rashi explains that in order not to disturb the joy of matan Torah, their sentence was suspended until they brought a foreign flame to the altar at the time of the inauguration of the Mishkan.
 Tehillim 19:10
 Sanhedrin 7A
 Eichah 2:20
 Tanchuma, Balak
 Bava Kama 38B
 Tanchuma Balak
 Sotah 35A