Parshat Shmini seems to contain four somewhat disparate elements. First we have the dedication of the Mishkan, the home of G-D and the focal point of the worship of the Jewish People. Then the death of two of Aaron's sons during what should have a joyfull time and then two sets of laws are given, laws of Kashrut and some laws of impurities. One might ask what is the connection between these things.
The last pasuk of the parsha gives us a hint, it begins with Lehavdil, to distinguish, bein hatamea ubein hatahor, between the impure and the pure. By placing impure before pure, the emphasis is and priority is placed on dinstinguishing the impure. We might normally think that it would make more sense to place the pure first as more important to distinguish than the impure, yet this is not so.
When discussing the laws of Kashrut, animals that have one sign of Kashrut but not both are emphasized as unclean, particularly the pig which has become a byword in Yiddish, a Chazzer Fissl, a pig's foot meaning a hypocrite who pretends to be pure on the outside as the pig stretches forth its cloven hooves to pretend it is Kosher while on the inside does not chew its cud and so is in fact not Kosher. Thus a distinction must be made, not everything that seems pure is pure and not everything that seems clean is clean, we must investigate and determine for certain.
The Rashi on Lehavdil, emphasizes that it is not enough to merely study the signs but to be able to actually distinguish them. There are different views on why Nadav and Avihu died but the Pasuk clearly emphasizes the main reason in what they did wrong, they brought an Eish Zara Asher Lo Tziva Otam, a strange fire that G-D had not commanded. It is no coincidence that the previous Parsha is Tzav and that it concludes with 'And Aaron and his sons did all the things that Asher Tziva Hashem, which G-D commanded.' The previous Pasuk before that has Moshe relaying G-D's commands with the threat of death again using the words Tzuveiti, as I am commanded. Nadav and Avihu however failed to distinguish between the form of worship they wanted and G-D's commands and thus were punished.
These are similar things after all, they were both forms of worship to Hashem, they were not committing idolatry, yet they failed to make a distinction between things that may outwardly seem good much like the pig's cloven hooves but are inwardly wrong. Worshipping Hashem is a good and great thing but worship of the kind that Hashem did not want and disobeying what he did command, is inwardly wrong. Similarly many self-righteous people may think they are worshiping Hashem but if what they are doing is not what Hashem has commanded, regardless of how great they may be, they are bringing a strange fire, a pig's foot that may seem outwardly good but inwardly not Kosher.
Moshe Rabbeinu then tells Aaron after their deaths, this is what G-D means Bekrovai Ekodesh, through those who are close to me I will become holy. As the Parsha concludes it emphasizes twice that we must be holy as G-D is holy using once again the word Kadosh. Vehayitem Kedoshim Ki Kadosh Ani and you shall be holy for I am holy. Closeness to G-D and our status as the chosen people demands holiness. The Pasuk goes on warning against defiling our soul's with impure things and thus explains why the distinctions must be made, they must be made to maintain our holiness.
Distinctions are the essence of Judaism and of this Parsha. The Mishkan itself is full of distinctions, the outside and the insider, the Shulchan where the physical bread is and the Aron where Hashem's Shekhina resides. Indeed it is said to be reflective of every part of the human body. Similarly a person must then make of his body a Mishkan Mei'at, a little Mishkan that is also sanctified to Hashem. By failing to make distinctions Nadav and Avihu defiled the Mishkan of G-D, the Parsha then goes on to teach the distinctions on foods and creatures that keep our little Mishkans holy.
Shmini is the eight day and the name of our Parsha, in the week the eight day is sunday or the day after Shabbat. At the end of Shabbat we make Havdalah during which we say Hamavdil Bein Kodesh Lehol Ve'Or Le'Hosech Ve'Yisrael Le'Amim, Ve'Yom Hashvi Le'Sheshet Yemei Hamaaseh, Baruch Ata Hashem Hamavdil Bein Kodesh Le'Hol; He Who Distinguishes between Holy and the Mundane, between Light and Darkness and between Israel and the Nations and the Seventh Day and the Six Days of Work, Blessed are you Hashem who distinguishes between the Holy and the Mundane. By classing these things together we assume a linkage, Kodesh Le'Hol is the actual blessing and is mentioned twice and the others are sandwiched in between it. Light and darkness, Israel and the Nations, and Sabbath and the other six days; all these are corollaries of distinguishing between the holy and the mundane. If we cannot distinguish between the holy and the mundane, there is no longer any distinction between darkness and light, between the jews and the rest of the world and the Sabbath itself vanishes. This distinction between the holy and the mundane underpins all the spiritual essence of existence.
We can see today in the world that moral equivalence and a lack of distinctions undermines and ultimately destroys any moral sense in society and any understanding of right and wrong. As Yeshaya HaNavi bemoans, good is called and evil good, darkness called light and light called darkness. No one any longer makes distinctions and as a consequence of that evil flourishes. It is important Lehavdil, to distinguish between the impure and the pure. The failure to do that makes all of society and the world impure. It may begin with things that seem outwardly good, like the chazzer fissl, that seem Kosher when on closer inspection they are not; it ends with erasing all the barriers between good and evil, right and wrong, holy and unholy and darkness and light.
The Mishkan was formed to create distinctions, the service of Hashem by the Kohanim was formed with distinctions. Distinctions between the various parts of the Mishkan and the various parts of the service, between the Kohen Gadol and the other Kohanim and the Leviim and Klal Yisrael as a whole, between the various sacrifices and where the various sacrifices could be brought and how the service was performed for them. Previously this had been gone into in great detail yet the lesson had not been learned and Nadav Avihu did not make the distinction s that Hashem had mandated but did as they wanted and so now Shmini teaches us instead the distinctions between clean and unclean and pure and impure which underlie all divine service. If we are to be a holy people, the service required of us is to remain holy and to reject impurity whether in the obviously un-kosher bugs or the more subtly un-kosher pig. All are ultimately impure and the distinctions between them are the distinctions that keep us close to G-D.