Ganesha is offered Durva grass, a special grass with 3 or five blades. An offering of this grass is of great importance and worship of Ganesha without durva is incomplete. In the Ganesha Atharvashirsha of Ganesha Upanishad It is said that
यो दूर्वाङ्कुरैर्यजति स वैश्रवणोपमो भवति । यो लाजैर्यजति स यशोवान् भवति । स मेधावान् भवति । यो मोदकसहस्रेण यजति स वाञ्छितफलमवाप्नोति । यस्साज्यसमिद्भिर्यजति स सर्वं लभते स सर्वं लभते ॥१६॥
He who worships (Ganapati) with tender Durva Grass will become Prosperous like Kubera (16.1:). He who worships (Ganapati) with Parched Rice will become Glorious (i.e. will have Name and Fame) [16.2:]. He will (also) become Medhavan (filled with Medha or retentive capacity of the mind) [16.3:]. He who worships (Ganapati) with thousand Modakas, he will obtain his Desired Fruits [16.4:] He who worships (Ganapati) with Twigs dipped in Ghee, he obtains Everything, he obtains Everything [16.5:].
This grass is said to be glorified in the Vedas and Puranas equally. According to Bhavishaya Purana durva is said to appear to form the hands and thigh of Vishnu when he held the Mandar mountain as a kurma avatar, during Samudra Manthan, The Vanaman Purana has a similar narrative but instead of kurma its Vasuki’s tail, the snake that was used to churn the ocean that led to the creation of durva.
As per the legend in Ganesha Purana, Upasana Khanda, there was a demon called Analasur, who petrified the three worlds, devatas went to lord shiva for assistance, and shiva asked them to seek help from Ganesha. The devatas asked Ganesha for help, Ganesha attacked Analasur and fought a ferocious battle, and ended up swallowing the demon.
This built up a lot of heat inside Ganesha and caused him great distress. To calm the heat king of gods Indra gave him the moon to wear, He was known as Bhalachandra. Lord Vishnu gave his lotus flower, but nothing seemed to work. Finally, some rishis offered durva grass along with Vedic mantras. Durva grass immediately relieved Ganesha of the unbearable heat. This pleased Ganesha and since then durva became a mandatory offering to Ganesha.