The story is that, before going to bath Parvati applies turmeric to her body, as it removes dirt. Once it gets dry, she removes flakes of it and creates a boy, Ganapati. She gives him a job, not to allow anyone to enter inside, till she comes back from her bath.
After some time Shiva gets obstructed by Ganapati, while entering inside to meet Parvati. Angered Shiva cut Ganapati's head. Then he realizes the facts from Parvathi and makes Ganapati alive by replacing Ganapati's head with an elephant's head.
A big doubt which comes into our mind is, how there was dirt on the Goddess Parvathi's body?
Parvati represents Prakruthi or Nature with the three qualities or gunas. They are Sathvik guna, Rajo guna and Thamo guna. The whole universe exists by these three qualities. The incompleteness that spring up because of these three qualities is a blockage for the Nature's role. "Incompleteness" was the boy created my mother Parvathi or Nature at the entrance.
Shiva represents complete awareness or pure consciousness. As light does not identify dark and gets spread through it, Shiva also do not identify blockage or dosha and remove the impureness. But it is not possible for the Nature or Prakriti or Parvathi to remain without incompleteness or impurity. Shiva solved this problem by replacing the head of an elephant, which represents knowledge to the blockage or dosha. Nature's blockages or doshas can be taken care by knowledge. This is the true meaning of Ganapathi being killed. That is why people worship Ganapathi to remove obstacles and give knowledge.
Ganpati is definitely a formless Parabrahman or highest brahmin. Devotees worship him in an idol prepared by a mud for a certain period of time. Then they fill Ganapati or knowledge in their heart and the idol or obstacle is merged in the water. This religious ritual is performed for devotees interest, not for Ganpati's interest.
Ganapati, a formless being is raised in a form and then his soul is raised back into one's heart as the idol is merged into the water.
- by Sri Sri Ravi Shankar