The beginning of Parshas Shmini describes the sacrifices brought during the days of the consecration of the mishkan. Both a calf and a goat were brought as atonement offerings. The fact that both were brought seems unusual. The Ramban quotes the Toras Kohanim, which says that the calf was brought as an atonement for the Golden Calf, and the goat was brought as an atonement for the selling of Yosef. What is the link between these two sins and the building of the mishkan?
The Medrash Tanchuma explains that the sin of the Golden Calf was not simple idol worship, but rather was a misguided attempt by Am Yisroel to develop a channel for their service of Hashem. The Meshech Chochma says that Moshe broke the tablets because Am Yisroel would have illegitimately used them in the same manner as they did the Golden Calf, and Moshe wanted to show that nothing can be done without the command of Hashem. Furthermore, the Beis Halevi explains that even that which is a legitimate need requires a mattir (Divine approval). While Am Yisroel craved the presence of Hakadosh Baruch Hu, rather than creating the Golden Calf they should have waited to see what form of service Hashem would command. That is why the Torah always stresses that Betzalel, who was charged with the construction of the mishkan, was a descendant of Chur, who had nothing to do with the sin of the Golden Calf. Betzalel 's heritage was based on acting solely on the word of Hashem, and the mishkan itself was "ka'asher tzvia Hashem" ("as G-d commanded"). Therefore, the consecration of the mishkan was an appropriate time to atone for the Golden Calf, as the "ka'asher tzvia Hashem" of the mishkan corrects the flawed attitude which resulted in the unsanctioned Golden Calf.
The Ramban writes in the beginning of Parshas Teruma that the Mishkan's purpose is to capture and foster the unity which was present when the Jews received the Torah on Har Sinai. Yerushalayim itself, the home of the Beis Hamikdosh, is described in Tehillim as "Yerushalayim hab'nuya, ke'ir shechubra la yachdav." The medrash interprets this verse to mean "shesham na'asim kol Yisrael chaveirim", i.e. a sense of unity pervades in Yerushalayim. And similarly, Rashi (on the verse "Lo ta'asun ken la Hashem Elokeichem") points out that whereas other religions have multiple holy sites, all Jews have only Yerushalayim. Therefore, building the mishkan, an entity which creates unity in Am Yisrael, is an atonement for the selling of Yosef, which was the result of discord and hate among the brothers. The Gemara (Shabbos 10b) tells us that the sin of selling Yosef brought about the exile in Egypt. Baseless hatred brings about the exile and the destruction of the unifying Beis haMikdash.
In this light, one can understand the sin of Nadav and Avihu. At first glance, what they did does not seem to be such a grievous sin. If one understands, however, that the Golden Calf represents a misguided attempt to serve G-d, then the unsanctioned sacrifice of Nadav and Avihu undermined the purpose of the Mishkan, which atoned for the Golden Calf. No one can determine new form of avodas Hashem. This is why the verse describes the actions of Nadav and Avihu as "Asher lo tziva osam," G-d had not commanded them.
The Gemara (Eruvin 63) relates another element of the sacrifice of Nadav and Avihu. They were guilty of teaching a Halacha in front of their rebbeim - they saw this as an opportunity to rise to power and undermine the leadership of Moshe and Aharon. This contentious sacrifice undermined the unifying aspect of the mishkan, which atoned for the sin of selling Yosef. Their sin was both bein adam lamakom and bein adam lachaveiro, and that is why the response was so severe and immediate.