Our Gemara on amud aleph and beis discusses an encounter between Rabbah bar Avuha and Elijah the prophet:

 

אַשְׁכְּחֵיהּ רַבָּה בַּר אֲבוּהּ לְאֵלִיָּהוּ דְּקָאֵי בְּבֵית הַקְּבָרוֹת שֶׁל גּוֹיִם, אֲמַר לֵיהּ: מַהוּ שֶׁיְּסַדְּרוּ בְּבַעַל חוֹב? אֲמַר לֵיהּ: גָּמַר ״מִיכָה״ ״מִיכָה״ מֵעֲרָכִין. גַּבֵּי עֲרָכִין כְּתִיב ״וְאִם מָךְ הוּא מֵעֶרְכֶּךָ״, גַּבֵּי בַּעַל חוֹב כְּתִיב ״וְכִי יָמוּךְ אָחִיךָ״. 

 

The Gemara relates: Rabba bar Avuh found Elijah standing in a graveyard of gentiles. Rabba bar Avuh said to him: What is the halakha with regard to making arrangements for the debtor? Elijah said to him: A verbal analogy is derived from the usage of the term “poor” written in the context of a debtor and the term “poor” written in the context of valuations. With regard to valuations, it is written: “But if he is too poor [makh] for your valuation” (Leviticus 27:8), and with regard to a creditor, it is written: “But if your brother be poor [yamukh]” (Leviticus 25:35). 

 

מִנַּיִן לְעָרוֹם שֶׁלֹּא יִתְרוֹם? דִּכְתִיב: ״וְלֹא יִרְאֶה בְךָ עֶרְוַת דָּבָר״. 

 

Rabba bar Avuh now asks Elijah another question: From where is it derived with regard to a naked person that he may not separate teruma? He replied: As it is written: “And He see no unseemly thing in you” (Deuteronomy 23:15). This verse indicates that one may not recite any words of sanctity, including the blessing upon separating teruma, in front of one who is naked. 

 

אֲמַר לֵיהּ: לָאו כֹּהֵן הוּא מָר? מַאי טַעְמָא קָאֵי מָר בְּבֵית הַקְּבָרוֹת! אֲמַר לֵיהּ: לָא מַתְנֵי מָר טְהָרוֹת? דְּתַנְיָא, רַבִּי שִׁמְעוֹן בֶּן יוֹחַי אוֹמֵר: קִבְרֵיהֶן שֶׁל נׇכְרִים אֵין מְטַמְּאִין, שֶׁנֶּאֱמַר: ״וְאַתֵּן צֹאנִי צֹאן מַרְעִיתִי אָדָם אַתֶּם״. אַתֶּם קְרוּיִין ״אָדָם״, וְאֵין נׇכְרִים קְרוּיִין ״אָדָם״. 

 

The amora proceeded to ask Elijah a different question and said to him: Is not the Master a priest? What is the reason that the Master is standing in a cemetery? Elijah said to him: Has the Master not studied the mishnaic order of Teharot? As it is taught in a baraita: Rabbi Shimon ben Yoḥai says that the graves of gentiles do not render one impure, as it is stated: “And you, My sheep, the sheep of My pasture, are man” (Ezekiel 34:31), which teaches that you, i.e., the Jewish people, are called “man,” but gentiles are not called “man.” Since the Torah states with regard to ritual impurity imparted in a tent: “If a man dies in a tent” (Numbers 19:14), evidently impurity imparted by a tent does not apply to gentiles.

 

Yaaros Devash (I.16) ties all of these three halachos together, so that the discussion during the visitation from Elijah was profoundly connected.  He explains the reason that a gentile does not capture impurity is ironically because he does not have a balancing potential for purity either.  This is an important spiritual principle:  There is always an equilibrium of capacity for purity and impurity. Much as a black garment does not show stains, the vessel that was the gentile’s body, devoid of the Torah, is empty and not receptive for either purity or impurity.  He takes this further with a graphic metaphor, why do flies gather around something dead that was once living instead of a stone?  The loss of life-power produces a particular kind of rot.  Thus, the Jewish corpse, which once embodied spiritual purity, also embodies a powerful backlash of impurity upon the soul’s exiting of the body.

 

But what will you say about a Jew who did not observe the Torah?  While, in some way, this is tragic, he is like a debtor.  He owes Hashem these observances, and therefore we allow him to make a payment plan, so to speak, like a debtor.  Therefore, he is not spiritually bankrupt and his body is still a vessel for spiritual purity and then can also become intensely impure.

 

The final discussion about the person who cannot take Terumah whilst being naked can be interpreted as follows (I am consciously diverging from the Ya’aros Devash, though he says something similar.) The gentile might object and say, he too can voluntarily do mitzvos and so he too should have potential for the purity-impurity effect.  The response to this claim is that the naked person cannot enact and sanctify the Terumah. Meaning, a person who is naked from mitzvos (see Midrash Tehillim 6:1) cannot just spontaneously decide to enact this spiritual potential on a one time basis.