The Talmud discusses the prohibition against teaching Torah to a non-Jew, deriving from the verse 'Torah commanded to us' (Devarim 33:4) — it is a morasha (inheritance) for Israel alone. The Talmud compares a non-Jew who engages in Torah study to a High Priest.
וְאָמַר רַבִּי יוֹחָנָן: גּוֹי שֶׁעוֹסֵק בַּתּוֹרָה חַיָּיב מִיתָה, שֶׁנֶּאֱמַר: ״תּוֹרָה צִוָּה לָנוּ מֹשֶׁה מוֹרָשָׁה״, לָנוּ מוֹרָשָׁה וְלֹא לָהֶם. וְלִיחְשְׁבַהּ גַּבֵּי שֶׁבַע מִצְוֹת? מַאן דְּאָמַר ״מוֹרָשָׁה״ – מִיגְזָל קָא גָזֵיל לַהּ. מַאן דְּאָמַר ״מְאוֹרָסָה״ – דִּינוֹ כְּנַעֲרָה הַמְאוֹרָסָה, דְּבִסְקִילָה. מֵיתִיבִי, הָיָה רַבִּי מֵאִיר אוֹמֵר: מִנַּיִין שֶׁאֲפִילּוּ גּוֹי וְעוֹסֵק בַּתּוֹרָה שֶׁהוּא כְּכֹהֵן גָּדוֹל? שֶׁנֶּאֱמַר: ״אֲשֶׁר יַעֲשֶׂה אֹתָם הָאָדָם וָחַי בָּהֶם״. ״כֹּהֲנִים לְוִיִּים וְיִשְׂרְאֵלִים״ לֹא נֶאֱמַר, אֶלָּא ״הָאָדָם״. הָא לָמַדְתָּ שֶׁאֲפִילּוּ גּוֹי וְעוֹסֵק בַּתּוֹרָה הֲרֵי הוּא כְּכֹהֵן גָּדוֹל. הָתָם, בְּשֶׁבַע מִצְוֹת דִּידְהוּ.
And Rabbi Yoḥanan says: A gentile who engages in Torah study is liable to receive the death penalty; as it is stated: “Moses commanded us a law [torah], an inheritance of the congregation of Jacob” (Deuteronomy 33:4), indicating that it is an inheritance for us, and not for them. The Gemara challenges: But if so, let the tanna count this prohibition among the seven Noahide mitzvot. The Gemara explains: According to the one who says that the verse is referring to the Torah as an inheritance, this prohibition is included in the prohibition of robbery, as a gentile who studies Torah robs the Jewish people of it. According to the one who says that the verse is referring to the Torah as betrothed, as the spelling of the Hebrew word for betrothed [me’orasa], is similar to that of the word for inheritance [morasha], the punishment of a gentile who studies Torah is like that of one who engages in intercourse with a betrothed young woman, which is execution by stoning. The Gemara raises an objection to Rabbi Yoḥanan’s statement from a baraita: Rabbi Meir would say: From where is it derived that even a gentile who engages in Torah study is considered like a High Priest? It is derived from that which is stated: “You shall therefore keep My statutes and My ordinances, which if a man does he shall live by them” (Leviticus 18:5). The phrase: Which if priests, Levites, and Israelites do they shall live by them, is not stated, but rather: “A man,” which indicates mankind in general. You have therefore learned that even a gentile who engages in Torah study is considered like a High Priest. The Gemara answers: There, in the baraita, the reference is to a gentile who engages in the study of their seven mitzvot. It is a mitzva for a gentile to study the halakhot that pertain to the seven Noahide mitzvot, and when he does so he is highly regarded.