“If someone tells you, ‘There is wisdom among the nations,’ believe it; ‘There is Torah among the nations,’ do not believe it” (Lamentations Rabba 2:13).
Wisdom can be found anywhere.
One can learn even from an animal – as it says, “Who teaches us by the beasts of the earth” (job 35:11) – and certainly one can learn wisdom from someone who is not a member of the covenant.
A person can be both a great mathematician and an adulterer, but it cannot be that someone who transgressed the laws that are found in Parashot Aharei Mot or Kedoshim is also a true Torah scholar.
Torah, which belongs to the kabbalistic category of “wisdom of holiness,” can be found only where there is holiness – and holiness does not go together with baseness.
The requirements of holiness are much stricter.
Rabbi Adin Steinsaltz