The Gemara states as follows:
תנא דבי רבי ישמעאל: עבירה מטמטמת לבו של אדם, שנאמר "ולא תטמאו בהם ונטמתם בם" אל תקרי ונטמאתם אלא ונטמטם. תנו רבנן: "ולא תטמאו בהם ונטמתם בם", אדם מטמא עצמו מעט - מטמאין אותו הרבה, מלמטה - מטמאין אותו מלמעלה, בעולם הזה - מטמאין אותו לעולם הבא. תנו רבנן "והתקדשתם והייתם קדשים" אדם מקדש עצמו מעט - מקדשין אותו הרבה, מלמטה - מקדשין אותו מלמעלה, בעולם הזה - מקדשין אותו לעולם הבא.
It was taught in the yeshiva of R' Yishmael: Sin dulls the heart of man, as it is written, "Do not sully yourselves with them [by eating insects], lest you become defiled." Do not read this as "become defiled" (v'nitmeisem), but rather "become dull" (v'nitamtem). Our Sages taught: "Do not sully yourselves with them, lest you become defiled." If a person sullies himself with even a small amount of sin, he becomes greatly defiled. If he sullies himself on earth below, his soul is defiled in Heaven above. If he sullies himself in this world, he will remain defiled in the World to Come. Our Sages taught: "You shall sanctify yourselves and you shall be holy." If a person sanctifies himself with even a small amount of mitzvos, he becomes greatly holy. If he sanctifies himself on earth below, his soul becomes holy in Heaven above. If he sanctifies himself in this world, he will remain holy in the World to Come." All mitzvos serve to heighten the sanctity of the Jewish soul, while all aveiros defile it. Nevertheless, we see from this Gemara that forbidden foods have a particularly harmful effect on the soul. Forbidden foods cloud our thoughts and engender in our hearts ignoble character traits that hinder our religious devotion. Even permitted foods can damage the soul, if they derive from an impure source. For this reason, the Rema advises against having a non-Jewess nurse a Jewish baby. Although her milk is technically kosher, it can still taint the baby's heart with traits inappropriate to a Jewish child. Therefore, if a Jewish nursemaid is available, the baby should not be allowed to nurse from a non-Jewess. Similarly, a nursing woman should not eat forbidden foods, nor should the baby itself eat them, lest the forbidden food leave a harmful influence on the baby's soul that will damage him as he grows older. The Shach explains that although a Jewish mother is anyway forbidden to eat non-kosher food, if she must do so to save her life then someone else should nurse her baby, lest the non-kosher food harm her baby's soul. This is an intriguing point. If her life is in danger, then she is not only permitted, but actually obligated to eat the forbidden food. Nevertheless, it still imparts a negative influence on the baby through the milk that is formed from it. (However, in such a case it seems clear to me that the mother herself will suffer no harm from the forbidden food. She has a mitzvah to eat it in order to save her life. It is inconceivable that her fulfillment of this mitzvah can cause her spiritual harm. The baby, on the other hand, has no mitzvah to nurse from its mother. Therefore, the Rema warns that the forbidden food can harm the baby's soul.) The Or Zaru'ah writes that if a sick person must eat meat to save his life, it is better to slaughter an animal on Shabbos to feed him kosher meat, than to feed him treif meat. He explains that eating treif is a "lowly solution", even when necessary to save a life. Therefore, one should instead choose to desecrate Shabbos, relying on the allowance made for the sake of piku'ach nefesh. He furthermore suggests that one might even be allowed to sacrifice his life rather than eating treif. Here too we see that eating treif, more so than other prohibitions, is extremely damaging to the soul. The Mesillas Yesharim therefore writes:
המאכלות האסורות מכניסים טומאה בלבו ובנפשו של אדם עד שקדושתו של המקום ברוך הוא מסתלקת ומתרחקת ממנו. והוא מה שאמרו בש"ס גם כן "ונטמאתם בם - אל תיקרי ונטמאתם אלא ונטמתם", שהעבירה מטמטמת לבו של אדם, כי מסלקת ממנו הדיעה האמיתית ורוח השכל שהקדוש ברוך הוא נותן לחסידים, כמו שאמר הכתוב "כי ה' יתן חכמה." והנה הוא נשאר בהמיי וחומרי משוקע בגסות העולם הזה. והמאכלות האסורות יתירות בזה על כל האיסורין, כיוון שהם נכנסים בגופו של האדם ממש ונעשים בשר מבשרו.
Forbidden foods infect the heart and soul of man with impurity, forcing the holiness of Hashem to depart him. Our Sages warn, "Do not sully yourselves with them [by eating insects], lest you become defiled." Do not read this as "become defiled" (v'nitmeisem), but rather "become dulled" (v'nitamtem). Sin numbs the heart, depriving it of the true wisdom and discernment that Hashem gives to the devout, of which the verse states, "For Hashem gives wisdom." Without this wisdom, a person is left like a coarse animal, submerged in the physicality of this world. Forbidden foods are more harmful in this way than any other sin, since they enter man's very body and become a part of his flesh. The Gemara tells the story of R' Pinchas ben Yair, whose donkey refused to eat the grains it was given until R' Pinchas realized that the grains might not have been tithed. R' Pinchas tithed them, and the donkey immediately began to eat. The Gemara concludes from here, "If Hashem protects even the animals of the righteous from sin, He certainly protects the righteous themselves." Tosefos notes that there were many instances in which the Sages of the Talmud did accidentally sin. Therefore, he concludes that Hashem protects the righteous specifically from forbidden foods, like the un-tithed grains that the donkey refused to eat. Tosefos explains the distinction between accidentally eating treif and accidentally transgressing other sins, by stating that, "It is disgraceful for a tzaddik to eat non-kosher food." Hashem protects the righteous from this disgrace. We might also add that when a person accidentally sins, he cannot be considered wicked. He must do whatever is necessary to atone for his mistake and is thereby forgiven. However, when a person eats non-kosher food, even by accident, it becomes a part of his flesh, as the Mesillas Yesharim explains. He loses the "true wisdom and discernment that Hashem gives to the devout." Therefore, special intervention is necessary to protect the righteous from forbidden foods. The harmful influence of non-kosher food is most poignantly illustrated by the story of Elisha ben Avuya, the Mishnaic Sage who eventually abandoned Torah observance and become known as "Acher – the Other One," signifying his complete change of identity. His sins were so heinous that a Heavenly voice declared, "'Return O wayward children' – except for Acher." Tosefos explains that Acher's fall from glory began before he was even born. When his mother carried him in her womb, she passed by an idolatrous temple and caught the smell of pork cooking. She was overcome with desire and partook of it. The forbidden meat "quivered within her like the venom of a poisonous snake," which infected her unborn child. Pregnant women are actually permitted to eat non-kosher food if they are so overcome with desire that they cannot control their longing for it. Nevertheless, the non-kosher food still damages the purity of her soul and the soul of her baby. Just as non-kosher food casts an adverse effect on the soul, kosher food casts an equal and corresponding benefit. Tosefos explains the roots of the unusual friendship that arose between Rebbe Yehuda HaNassi, the leader of the Sages, and the Roman leader Antoninus:
אמרינן במדרש חלב מטמא חלב מטהר. כשנולד רבי גזרו שלא למול ואביו ואמו מלוהו. שלח קיסר והביאו לרבי ואמו לפניו. והחליפתו אמו באנטונינוס והניקתו עד שהביאתו לפני קיסר ומצאוהו ערל ופטרום לשלום. ואמר אותו הגמון אני ראיתי שמלו את זה אלא הקב"ה עושה להם נסים בכל עת ובטלו הגזרה ואמרי' נמי בירושלמי שלסוף למד אנטונינוס תורה ונתגייר ומל עצמו.
The Midrash states: "Milk can defile and milk can purify." When Rebbe was born, the Roman government passed an edict forbidding circumcision. Rebbe's parents circumcised him nonetheless. The Caesar then ordered that Rebbe and his mother be brought to him. Rebbe's mother switched Rebbe with Antoninus, nursed Antoninus, and brought Antoninus before the Caesar as if he were her son. The Caesar saw that the baby was not circumcised and dismissed them in peace. A Roman governor then said, "I saw that their son was circumcised, but G‑d, as always, has performed a miracle for them." They then decided to annul the decree. The Talmud Yerushalmi adds that in the end Antoninus converted to Judaism and was circumcised. Having nursed milk from a righteous Jewish woman, Antoninus developed a natural affinity for holiness, causing him to revere the Sages and eventually convert to Judaism himself. We thus see that the balance between the sacred and the defiled, the holy and the mundane, depends on the purity of the food we eat. Great reward is in store for all those who are careful never to defile their souls with forbidden foods. The Midrash states that in the World to Come, Hashem will give forth a proclamation inviting all those who never ate pork to come and claim their reward. Many gentiles who happened to never have eaten pork will then come together with the Jews to share in our reward. "Must I reward these gentiles in both worlds?" Hashem will ask. "It is enough for them the benefits of this world that they enjoyed. Do they also seek to share the reward of My children in the World to Come?" The proclamation will then be amended to say instead, "Let all those who never ate treifos, neveilos or crawling insects come and claim their reward!" The full reward of the World to Come is reserved for those who purified their bodies in this world by allowing only kosher food to enter their mouths.