Rabbi Yoseph Mizrachi, my favorite Rabbi made the statement during one of his Lectures that the Written Torah is for the Nations and the Oral Torah is for the Nation of Israel so that the Nations cannot own the Torah. It also seems the opinion is split about this injuction against teaching the Torah. In fact, it all depends on the status of the Goy wanting to be taught. Nothing in Judaism seems to be clear cut when the rabbis themselves disagree and then try and clarify the differences.
Here is an Article from Noach.com that I found helpful.
• Torah to the Nations
"...and they encamped in the dessert."Exodus "The Torah was given in an ownerless place, for if it had been given in the Land of Israel the nations of the world would say that they had no part in it. Therefore it was given in the dessert, and anyone who wishes to receive it should come and receive."Midrash Mechilta ch.20
This passage requires deep study in view of the care taken by the Rabbis of the past to keep the Torah away from non-Jews and the many examples in the Torah which support this caution:
"A non-Jew who studies the Torah is deserving of death at the hands of Heaven", as it is said "the Torah which G-d commanded us as an inheritance"; "to us and not to them".Sanhedrin
"His status and his laws to Israel he declared; He did not do so to any other nation. and they so not know the Laws: Praise the L-rd." Psalms 147
The Zohar, source of the wisdom of Kabbala, points out at length the great transgression that is committed by passing on the Torah to non-Jews: "... any man who does not hold himself back from handing over even the smallest letter of the Torah is as if he had destroyed the world and told falsehood in the name of the Holy One, Blessed be He. For everything depends on it, as it is said: "If I had not established My covenant day and night, the laws of heaven and earth I would not have set"Jeremiah 33:25 and also "This is the Torah that Moses placed before the Children of Israel"Deut. 4:44 i.e. not before the other Nations.
Here the Zohar expresses the idea in terms of an unacceptability in teaching those who are uncircumcised, for all the words of Torah are Names of G-d, and to teach them to people in this condition would bring destruction to the world. We see the extent to which neither the Written nor the Oral Law should be taught, even the Ten COmmandments, as it is said, "to Israel they were given, not to the Nations".Midrash Rabbah to Numbers 8:4
We have seen above a view which seems to stand in direct contradiction to the previous view expressed. Though other statements confirm it.
"Each word that came forth from G-d was split into seventy languages.Shabbat 88b Rabbi Yochanan said, "the voice split into seventy voices for the seventy (root) languages, in order that each Nation should hear the voice in its own language."Midrash Rabbah to Exodus 85;19
Moses explained the Torah"Deut. 1:5 which the early commentators explain to mean that he gave its explanation in these seventy languages, and since the Jewish people had no use for the seventy language he must have intended each one for its' individual nation.
How did Israel write the Torah? On entering the Land of Israel the Jewish people were commanded to write the Torah on a monument on Mount Gerizim. Rabbi Judah said, "They wrote it on stones as it is said; And they wrote all the words of the Torah on stones and afterwards they plastered it over/Deut. 23:7 Rabbi Shimon said to him. "According to you how then did the nations of that time learn Torah? (since it was plastered over)
Rabbi Judah replied, "G-d gave them understanding, and they sent their scribes who peeled the plaster off (from the stones) and carried it away. From then on their fate was sealed, because they could have learned but did not."
Rabbi Shimon then said, "It was written on the plaster, and beneath it was written "In order that they shall not teach you to do all the abominations". This teaches that if they repented they would be received."
Hence we learn that in order to return the nations to the true path one must teach them Torah.
The RabbisSanhedrin address this contradiction: "Anon-Jew who learns Torah is deserving of death" whereas Rabbi Meir says, "Where does one learn that even a non-Jew who learns Torah is compared to the High Priest? as it is said, "which a man should do an live by them", neither Priest, Levite nor Israelite is mentioned here, but only "Man", meaning even a non-Jew..."
The response of the Gemara is that the non-Jew who earns praise is the one who learns that portion of the Torah which applies to him: the Seven Noachide Laws.
The Meiri explains: "If he would learn the Torah without intending to keep its basic laws, but only out of desire to learn our Torah, then he is liable to punishment, for people will see his knowledge and believe him to be a Jew, and thus be led astray. However, if he learns the Seven Commandments with their details and all that may be gleaned from them then even though the main body of our Torah is contained in them it is fitting to honour him as one would a High Priest."
We do not fear that he will cause others to err, since he is learning what is suited to himself, and all the more would it be permitted to teach him if he were conducting his investigation to ascertain the purpose of the whole Torah and thereby convert to Judaism completely.
Maimonides explores further:Laws of Kings 10:9 where he writes : "a non-Jew who learns Torah is deserving of death: he should only learn the Seven Commandments applicable to him."
In a responsum, however, he distinguishes between a non-Jew who accepts the holiness of the Torah and one who does not, ruling it permissible to teach the former, but not the latter because of the damage that might arise. Since all non-Jews must be taught the Noachide Laws the decision of Maimonides not to teach a section of them refer only to the rest of the Torah. As he himself writes:
"There is a question as to whether the statement of Rabbi Yochanan "a non-Jew who learns Torah is deserving of death" has the force of law; Also whether a Jew has alegall duty to hold himself back from teaching anything other then the Noachide Laws."
He answers that without any doubt this is the law, and that where the Jewish people are in a position of strength, one he should hold back from teaching the non-Jew until he converts. However the non-Jew does not become liable to the death penalty if he does learn Torah, in contrast to the position concerning all other transgressions of the Seven Laws, since the phrase used is deserving death", not "liable to death".
These laws may be taught to the Christians since they acknowledge the Divinity of the text of the Torah, but not a present to the Moslems since they deny it and any knowledge of its ideas would lead to error and become a stumbling-block for the Jews dispersed among them. If Christians are taught they are capable of accepting the ideas, and at any time their rejection of them would not cause further harm.
Some commentators distinguish between the Oral and Written Law: the former forbidden and the latter permitted, not because one is superior to the other but because they have different methods of transmission.Maharats - Chayot to Sotah 35b
Others forbid the Five Books of Moses but permit the Prophetic works and the WritingsBe'er Sheva, brought Magen Avraham ch. 334 par 17 There is also an opinion that if one is asked a question of the Five Books merely in passing it should be answered, for the sake of peace, as no ulterior motive is necessarily implied.
It should be understoodamongg the Sages over how to relate Torah to the non-Jewish world. They are merely contention over the aspect of teaching that is advisable at any given time.