“…And fire went forth from before G-d and consumed them, and they died before G-d…” – Vayikra 10:2
וַתֵּצֵא אֵשׁ מִלִּפְנֵי ה’ וַתֹּאכַל אוֹתָם וַיָּמֻתוּ לִפְנֵי ה’ – ויקרא י, ב
Why were Nadav and Avihu, the sons of Aharon, punished with sudden death? According to the opinion of R’ Yishmael cited in the Midrash (Vayikra Rabbah 12:1), they died because they entered the Mishkan while under the influence of wine. The proof, says R’ Yishmael, is that immediately following their death G-d warned Aharon and his surviving sons not to drink wine before entering the Mishkan. In support of this explanation, the Midrash relates a parable of a king who had a devoted domestic aide whom he once found at the entrance to a tavern. The king executed him without a word, and appointed another aide in his place. We might not have known why the first aide was put to death, continues the Midrash, but when the king instructed the new aide, “do not enter the doors of taverns,” the cause for the first aide’s execution became evident.
Rashi quotes this explanation in his commentary on the Torah and refers the reader to the Midrashic parable: “This is analogous to a king who had a domestic aide etc., as taught in Vayikra Rabbah.” Though he does not quote the parable in full, Rashi draws attention to its opening words. In doing so, Rashi addresses a most troubling issue raised by this explanation. How could Nadav and Avihu be punished for entering the Mishkan while intoxicated if they had never been instructed otherwise? The warning not to drink wine before entering the Mishkan was told to Aharon immediately after their deaths, not before!
To explain this, Rashi highlights that the Midrash compares Nadav and Avihu to a trusted aide to the king, a member of his household (ביתבן, in Hebrew.) The aide was held accountable for his behavior even though he hadn’t been warned to do otherwise, because as a member of the king’s household he should have intuitively sensed that such behavior was contrary to the king’s desire.
The same is true of Nadav and Avihu, of whom G-d told Moshe, “through those nearest to Me, I will be sanctified” (10:3). Even if entering the Mishkan after drinking wine had not yet been forbidden explicitly, yet as members of G-d’s household, as it were, the appropriate mode of conduct for the King’s house should have come to Nadav and Avihu instinctively…
—Likkutei Sichos, vol. 12, pp. 50-52