Once Ravana performed a sadhana and received as reward a jyotirlinga from Shiva himself. Shiva told Ravana to carry the jyotirlinga to his land with the caveat that wherever Ravana would place it, it would remain stuck there for ever.
So Ravana carried the jyotirlinga with great care. He held back every physical urge such as eating or attending to calls of nature and walked almost 4,000 kilometres from Kailash to a place called Gokarna in Karnataka. Since he had been walking without food or rest, he felt weak and he wanted to ease himself. Unable to eat any food, he must have sustained himself on water alone and his bladder must have been bursting. But he would not keep the jyotirlinga down either. And he would not be able to make water — an unclean act — while holding the jyotirlinga with his hands.
Presently, he saw a cute and innocent-looking cowherd boy. Ravana said to the boy, “Hey you, come here.” The boy came. Ravana said, “If you hold this for five minutes, I’ll give you a pearl necklace. Just hold it, don’t keep it down. Understand?” The boy agreed. Ravana gave the jyotirlinga to the boy and turned around to ease himself. His call of nature done, he turned around to look. What did he see? The boy had kept the jyotirlinga down and, of course, it had sunk into the earth as per the caveat. Then Ravana looked up. In place of the cowherd, it was Ganapati standing there, in his true form with a grin on his face.
Ganapati did not want Ravana to take the jyotirlinga to Lanka, because if he did, he would have become superhuman. Even today if you visit Gokarna, you will see a small hole in the rock through which you have to put your finger and feel the jyotirlinga. Ravana got so furious he knocked Ganapati on the head so hard that his head was dented. That is why you will also find a Ganapati statue with a depression in his skull at Gokarna.
For these thousands of years that day of Ravana-Ganapati encounter has come down to us as Ganesh Chaturthi. Ganapati, one of the most popular gods from India, is the one who mastered all the knowledge that was in the land. Even today when a child commences his education, the first thing parents do is invoke Ganapati, the scholar-deity. He is believed to like food. Usually scholars are skinny, but Ganapati is a well-fed, smart scholar, who outwitted Ravana.