Offering food to the Gods before eating is an essential custom of the Hindus during performing puja. Traditionally people offer food to the Gods which is known as Naivedya and then after the puja it is distributed as prasad to the devotees.
This ritual is practiced to imbibe the culture of gratitude among the people. We are indebted to many people and things in this world and it is our duty to express gratitude for all the things we receive.
We must remember that we came into this world empty handed and then got different things from different sources. Hence food which is the most important factor for our survival is treated as the gift of God and offered as Naivedya to him.
It is believed that when we do puja, God comes down to take our offerings symbolically and when we consume the leftover , we would get the blessings of the almighty.
Practicing this ritual imbibes the prasada buddhi in us which means we accept whatever is offered to us cheerfully. It decreases our cravings and we would learn to be thankful to all the things we are having in life. It develops the principle of counting our blessings.
Food is an important element with which we can clear our debts in a certain way to all the elements in the world. Hence even while eating food people offer some part of the food as clearing devata runa, pitru runa, rishi runa, manushya runa and bhuta runa.