The beginning of Parshat Acharei Mot records the Yom Kippur service as performed by the Kohen Gadol. Immediately before that, however, the Torah mentions that Hashem taught these laws to Aharon immediately after the death of two of his sons, Nadav and Avihu.
Anyone who has learned Rashi knows his favorite question at the start of a new section: Why is this section next to the one before it? In this case, the question is why the Torah mentions the death of Aharon’s sons in conjunction with the Yom Kippur service.
According to one interpretation, the sin of Aharon’s sons was bringing Ketoret to the Aron that was not asked of them. Interestingly enough, an important part of the Yom Kippur service is the Kohen Gadol’s bringing of the Ketoret in the Kodesh Hakodashim, in front of the Aron. Why would Hashem want to remind Aharon of the sin that killed his sons in the description of the Yom Kippur service?
We see a very similar idea in Parshat Shemini. Some commentaries indicate that the entire Mishkan served as an atonement for the חטא העגל. Then, on the eighth day of the inauguration of the Kohanim, Aharon is ordered to bring an עגל as a Korban Chatat – the very same animal that precipitated one of the greatest sins in Jewish history and prompted the building of the Mishkan.
In fact, Aharon himself was the one who built the עגל הזהב to begin with. Now he is reminded of his error, which cost more than three thousand lives, and told to bring a Chatat for it.
Perhaps we must look into the reason Nadav and Avihu were killed for their error to determine an answer. Nadav and Avihu were killed for bringing a “foreign fire,” meaning that God did not tell them to bring it. Their initiative was not appropriate because the Mishkan was not their domain to control. Since God needed to show Nadav and Avihu that he controlled the Mishkan, He killed them for their arrogance of presuming that they could bring their own Ketoret.
Bnai Yisrael were also punished for something one would not think is a sin. The nation created the עגל, according to some, because they needed something physical to represent God, something for them to relate to. Why were they punished for this? The Mishkan itself serves almost the same purpose, being a physical representation of Hashem and a place to serve Him.
Both the עגל and the Ketoret of Nadav and Avihu were strange sins because they were actions that are permitted under other circumstances. The one reason they were not permitted in those cases is because God did not command them. The underlying theme is that one cannot believe he controls the Mikdash. The Mikdash demands our subservience to Hashem and not His subservience to us.