Ganesaís mythical origins were initially developed in the Puranas, which date to about A.D 300 . Although there are several variations in his mythical origin, the most commonly agreed upon myth is listed as said earlier, in the Puranas.
According to it, Lord Siva had left his wife Parvati to meditate on Mt. Kailasa. In her loneliness, Parvati created a young man who could give her love and protection as a son. When Siva returned from his lengthy penance to Parvatiís private chamber, the protective young man refused to admit him. Not knowing this guardian son was Parvatiís creation, Siva, in a rage beheaded him. Parvati, stricken with grief and anger threatened to destroy the universe unless Siva restored her son with a new head upon his the shoulders. Siva then sent his minions in search of a head. Traveling north, these minions cut off and returned with the head of the first animal they came across, an elephant. Parvatiís son was revived with the new head and Siva, praised the revived being for upholding the dharma of a son and named him Ganesa. In reward, he also made him lord of his own group of devotees (ganas) and adopted him as his own son. Siva then decreed to all the Gods and Goddesses who were assembled there that henceforth, Ganesa must be worshipped before undertaking any endeavor or it will end in ruins.
Hence Ganesa become the Lord of Obstacles, placing barriers for those who
forgot to worship him and the Lord of Beginnings, for he also brought success
to those who sought his blessings before any undertaking. This then explains
Ganesaís mythical creation, omni -presence, popularity and location in
all if not most Hindu Temples.
The Symbolism of Elephants in Indian Culture
The Lord Dranketh