During the festival of Ganesh Chaturthi every one is busy cooking Modaks, the sweet shops sell varieties of Modaks. Ganesh loves the sweet stuffed rice or Khoya dumplings. It is said that in the early Sanskrit literature Modaka appeared to have the similar resembles as laddu or ladduka. In Anushasan Parva of Mahabharat and Yuddha Kanda of Ramayana Modaka is mentioned. It is believed that after this era Modaka became associated with Ganesha. The Shushruta Samhita mentions Madhumsaka or Madhukroda as a sweet which was prepared with wheat flour but had honey or clarified butter stuffed inside. The Agni Puran also mentions Morendaka was a kind of sweet prepared from curdling the milk. The solid part of it was formed into the shape of the eggs of a peacock, fried in clarified butter and coated with sugar. The Mansollasa by King Someshwara the II, Mentions Modaka as prepared with rice flour, sugar and some aromatic spices such as cardamom and camphor were called Varsopalagolakas because they looked like hailstones as mentioned in Manasaollasa.
Once Anusuya, wife of sage Atri invited Lord Shiva with his family for lunch, Lord Shiva came along with goddess Parvati and Ganesha. They were served with delicious mouth-watering delicacies, Lord Ganesha then started eating and ate all the food that was served. Inspite of eating so much his hunger was not satisfied. Anusuya was really worried as sending a guest unsatisfied is a sin. Finally only thing that was left with Anusuya was a plate of Modak. She served Ganesha with 21 Modaks as her last resort. After eating the Modaks Lord Ganesha was satisfied.
There is another story where in Modak is referred as symbol of divne knowledge. One Shiva and goddess Parvati wished to present a unique divine Modak of knowledge to their sons. This Modak had the ability to bestow the person eating it with incredible knowledge of everything. Goddess Parvati decided to test her sons and decided to give it to the one who passes the test. She asked her sons to circumambulate the universe three times and the first one to do this would win. Kartikeya instantly flew on his peacock. Whereas Ganesha sitting on his mouse went around Lord Shiva and Goddess Parvati , giving the logic that for a son his parents are the universe and the universe revolves around Shiva and Parvati. By the time Kartikeya returned Ganesha had already won and received the Modak of knowledge.