“…And not explore after your heart and after your eyes after which you stray” (Bamidbar 15:39)
Rabbi Chananiah S’gan Hakohanim says: Whoever places divrei Torah upon his heart is spared thoughts of sword, hunger, folly, promiscuity, Yetzer Hara, adultery, idle matters, and the burden of flesh and blood. This is in line with the statement of David Hamelech (Tehillim 19:9), “The orders of Hashem are upright, gladdening the heart; the command of Hashem is clear, enlightening the eyes.” But one who does not place words of Torah on his heart is subjected to destructive thoughts, as we are warned in the Mishneh Torah of Moshe Rabbeinu (Devarim 28:46), “They will be a sign and a wonder, in you and in your offspring, forever, because you did not serve Hashem, our G-d, amid gladness and goodness of heart…” (Avot D’Rabbi Natan 20:1).
The beginning of sin is inappropriate thought, the next step is mockery, and the third is coarseness of spirit (Derech Eretz Zuta 6).
“You shall guard against anything evil” (Devarim 23:10). Rabbi Pinchas ben Yair says that from here we learn that one should not have improper thoughts by day, which might cause impurity at night (Ketubot 46a).
Rabbi Ami states that one who entertains improper thoughts is prevented from being close to Hashem, as the pasuk states, regarding inappropriate thoughts, “It was wicked in the eyes of Hashem,” and further (Tehillim 5:5), it states, “For You are not a G-d who desires wickedness, no evil sojourns with You” (Niddah 13a).
Thinking about a sin is more severe than doing the sin itself. Thinking about a sin is similar to the smell of meat, which is stronger than its taste (Yoma 29a).
Rashi remarks: The temptation to sin with a strange woman can weaken a man’s strength, even more than actually sinning. This is similar to one who smells roasting meat and has an urge to eat it.
The Maharal avers that this saying can be understood literally. This is not referring to actual sinning, for which one is punished with death or lashes. Rather, it refers to one who adheres to thoughts of abomination and licentiousness. In this matter, thinking about doing a sin is more severe than the sin itself. This is because thoughts are more powerful than deeds, since they are in the realm of the intelligence and are not mere physical acts (Netiv Haparashiyot 2).
Many rule that inappropriate thoughts are not considered sins. One receives neither reward nor punishment simply for his thoughts. There are many proofs to the contrary, but here is not the place to expound. I will just quote a few pesukim as examples of the significance of thought: We read (Mishlei 6:18), “A heart plotting iniquitous thoughts;” also (Divrei Hayamim II, 6:8), “You have done well by having this in your heart;” also (Tehillim 125:4), “To the upright in their hearts;” and (Devarim 30:14) it says, “In your mouth and in your heart – to perform it.” The central aspect of any mitzvah is the righteousness of the heart, as mentioned above. This is proven by the concept of intentional and unintentional sins (Ibn Ezra, Devarim 5:15).
The Ramban writes that merely thinking thoughts of licentiousness is called incest.
The Radak (Zechariah 7:10) asserts that merely thinking about a sin is forbidden, as we see from the transgression (Vayikra 19:17), “You shall not hate your brother in your heart.” Moreover, wrong thoughts bring one to sin.