Vayikra / Leviticus 15:31 · Drash
וְהִזַּרְתֶּם אֶת־בְּנֵי־יִשְׂרָאֵל מִטֻּמְאָתָם וְלֹא יָמֻתוּ בְּטֻמְאָתָם בְּטַמְּאָם אֶת־מִשְׁכָּנִי אֲשֶׁר בְּתוֹכָם׃
And you shall separate the children of Israel from their impurity, so that they do not die in their impurity by defiling My Mishkan that is among them.
Drash דְּרָשׁ
The trouble is not impurity but drawing near
The Torah does not forbid being impure: impurity comes to everyone. Shem MiShmuel points to the end of the verse.
Shem MiShmuel: impurity itself is permitted, but the evil is to approach the holy with it, "defiling My Mishkan". So too before a festival: what all year is not counted as evil stops being a small thing when the light of the festival comes. Therefore thirty days before a festival one must examine one's heart.
How Shem MiShmuel explain it
Shem MiShmuel And you shall separate the children of Israel from their impurity
"And you shall separate the children of Israel from their impurity, by defiling My Mishkan that is among them." For impurity itself: if a person wants to remain in his impurity, he is permitted. But the main evil is when he approaches the holy. So too is the matter of the thirty days before a festival, when every person must examine the recesses of his heart. Even though all year this is not counted as evil, heaven forbid, still, when the festival has come and a divine light comes to every person of Israel, so that it not be like eating holy things in impurity or like bringing impurity into the Sanctuary. And in the Talmud, tractate Avodah Zarah: for us, for whom a cataract in the eye is a blemish, thirty days are needed. And of a cataract in the eye and a "tusk on the lips" it is said in tractate Gittin that it is a place that for us is a blemish and for them is not. And this hints at "after your heart and after your eyes" (Bamidbar / Numbers 15:39): a cataract in the eye is "after your eyes", and a tusk on the lips is "after your heart", for the tongue is the pen of the heart. And this warning is enough for one who understands.
Takeaway
"Thirty days before a festival" is when one begins to study the laws of the festival (Talmud, Pesachim 6a).
Shem MiShmuel carries the laws of blemishes of an offering over to the soul: a flaw of the eye is what a person looks at, and a flaw of the lips is what he says.