There is an ancient saying, "The greatest evil is lust." I believe that there is definitely some truth to it.
By violating moral standards on lust, human beings have created significant amounts of karma. Before the decline in moral standards, people frowned upon those who had an attachment to lust.
In China during the Qing Dynasty (1644 – 1911 AD), Ji Xiaolan (1724 – 1805 AD), was a famous official and the chief editor of Siku Quanshu
(“Emperor’s Four Treasuries”: the largest collection of books in Chinese history). He wrote a book called Yue Wei Cao Tang Biji
(“The Thatched Study of Close Scrutiny”) in which he recorded many fantastic stories he had heard or personally experienced. One of the stories goes as follows:
The emperor sent an officer to Taiwan on official business. On his way to Taiwan he stayed at an inn. While there one day, he saw a gorgeous girl peeking over a wall into the courtyard where he was staying. Loudly and angrily, he rebuked her and sent servants to search for her, but they didn't find her.
While sleeping at night, the envoy was awakened by a sound and a piece of tile flying onto his pillow. Angry, he shouted, "What monster is out there who dares to insult the emperor's envoy?"
A girl's voice came from outside the window, "You are a fortunate official. I tried to avoid you during the day, but you saw me, scolded and searched for me. I did not want the gods to know about this and get blamed. Hence, I was really worried."
"However, when you went to bed, you were thinking that possibly I was the daughter of the owner of this inn. You were conceiving a plan to have me as your second wife. Of course you are not aware that any thought you entertain, the gods and evil spirits will know about it. Whenever a person conceives an evil thought, it will attract the harassment of an evil spirit. Under this circumstance, the gods will not fault the evil spirit. Hence, when I threw a tile at you, you really had no right to be angry."
Listening to her explanation, the envoy felt dejected and ashamed. Before daybreak, he ordered his servants to pack up and leave.
From the above story we can see where such sayings by the ancients as "There are gods three inches above everyone’s heads," and "When you entertain a thought, all of heaven and earth knows about it" come from. As soon as a person conceives a lustful thought, God will know about it and will despise the person. It will also be all right for an evil spirit to harass this person. Thus, one must not say or act in an obscene way, and must also avoid entertaining any wanton thoughts.