Do not regret lack of intelligence or strength - Shiva Maha-Purana 2.109

Brahma said, there have been many various Ganeshas in the many Kalpas. During the Shweta Kalpa, Ganesh was born to Shiva and Parvati, when they went to Kailash Mountain shortly after their marriage.

Parvati had decided to take a bath, and instructed Nandi to let no one enter the home without her permission. During her bath, Shiva arrived by chance. Despite Nandi faithfully conveying the message, Shiva went inside anyway - for it was his home, after all. Parvati did not like this at all - for it was also her home. She realized Nandi could not actually prevent Shiva from entering, so before her next bath she took the dirt from her body and made Ganesha. She instructed Ganesha to not allow anyone in without her permission - and gave him a stick as a weapon. By chance again, Shiva again arrived during the bath - he tried to ignore Ganesha but Ganesha was able to block the door.

Shiva realized at once that Ganesh could not be his servant - for if he was, like Nandi, he could not actually prevent him from entering his own home. At the same time, he was frustrated and furious. Shiva ordered the Ganas which accompanied him to kill Ganesh - Shiva rarely went anywhere without his Ganas (perhaps you can see why Parvati would want privacy during her bath?)

The Ganas attacked Ganesha, but none were a match for him. After being defeated by Ganesha, the Ganas went to Shiva, and asked what to do? At that moment, Brahma and Vishnu, together with many Gods, noticing Shiva was home, came to visit (perhaps you can see why Parvati would want privacy during her bath?)

Brahma decided he would reason with Ganesh. But as soon as he got close enough to Ganesh, Ganesh attacked Brahma! Shiva rushed to defend his brother, and then fought Ganesha in single combat. At first, Ganesh dominated the battle, and was at the point of overcoming Shiva. Shiva realized at that moment that he could show no restraint with Ganesh - and so, with his full strength, he utterly destroyed the head of Ganesha with his Trishul.

Parvati had been admiring Ganesha, and saw his death. At the death of her valiant servant, she grew so angry that she manifested every one of the forms of Shakti, and began to destroy every world. The Gods were terrified, and sought the protection of Shiva, Brahma and Vishnu - but found no refuge. So the Gods begged Shakti for mercy. Shakti said the condition of her pardon would be that Ganesha would be brought back to life - and equal to any of the Gods, equal to even Shiva, Vishnu, or Brahma.

The Gods begged Shiva to make Ganesha alive again. Shiva perceived the danger clearly, and knew there was no shame in being overmatched by Shakti's strength. But Ganesh's head had been completely destroyed! So he and sought about for a new head - and asked his brothers, and all the Gods to help him. Some offered them their own heads - but not any head would do - they would need to go north of there, and find and a head facing north. Indra commanded his vehicle, an elephant, to lay down and face north - at the same time that the Goddess Malini, drinking the the bath water of Parvati (which contained those bits of dirt that she had not removed to make Ganesh), gave birth to Parvati's desire - a reincarnated Ganesh. But this reincarnation had 5 elephant heads (because Malini had birthed him). Shiva combined the dead body with the reincarnation and the head of Indra's elephant. To confirm that Ganesh was in fact equal to anyone, all the Gods worshiped him in the way they would worship Brahma, Vishnu, Shiva or Shakti - and Brahma, Vishnu and Shiva all acknowledged him as their equal. Shakti was pacified, and retook the form of Parvati.

Ganesha had an "older" brother, Kartikeya. The two got along well, except once. Both wanted to be married first - Kartikeya said, he was eldest. But Ganesh said he was equal to Shiva, Brahma, Vishnu - and any God, and deserved the honor by right. Shiva and Parvati consulted together to find a solution to this problem: they told their two sons that whoever would return first after circumambulating every world would get married first.

Ganesh thought he was at a disadvantage, as Kartikeya's vehicle was a peacock and could fly very fast - much faster than Ganesh's mouse. After setting out, Ganesh received some help - Vishnu and Brahma helped him understand! And he found a wife, Buddhi, who also helped him become so much smarter. So Ganesh returned to his parents and asked them to sit together. He circumambulated them and said, "according to the Veda, circumambulating one's parents give virtues equivalent to that of circumambulating the whole earth. So, now you must get me married first." Shiva and Parvati were both very impressed by his intelligence. So they arranged for him to be married to Siddhi and Riddhi, the daughters of Vishwaroop Prajapati. In due course of time, they had two sons: Kshem and Labh.

Eventually Kartikeya returned from his journey, and saw Ganesh had already been married - and had sons. He felt sad, as if he had been cheated. And began to feel jealous. He greeted his whole family, then went off to Kraunch Mountain to meditate. Parvati felt the sadness of her son, and so she and Shiva went on pilgrimage to Kraunch Mountain. This is why having a Darshan of Kartikeya (studying Kartikeya) on the full moon day of Kritika Nakashatra is so auspicious, for remembering how Shiva and Parvati comforted Kartikeya destroys the regrets of lack of intelligence or strength.

[Kartikeya eventually married Devasena and Valli, and lived happily ever after, too - with Ganesh, Siddhi, Riddhi, Kshem, and Labh - but that is another story]