It is said that one day Lord Ganesha and Kartikeya, sons of Lord Shiva and Goddess Parvati, were having an argument as to who of the two was more wise and superior. When they went to their parents to settle the matter once and for all, Goddess Parvati had an idea. She told the two to have a race. The winner would not only gain bragging rights but also receive a divine fruit.
The race was simple. Both of them had to roam around the world thrice, whoever completed three rounds of the earth first would be declared the winner. Without giving a further thought, Kartikeya sat on his peacock (his vahana) and started roaming the world. Ganesha, however, knew that on the merit of speed his mouse would not be able to match the peacock. So he thought for a while.
Meanwhile, Kartikeya completed his first two rounds and set off for the third. A perplexed Ganesha thought of a solution. He arranged a comfortable seating for Lord Shiva and Goddess Parvati. He then joined his hands and took three rounds of his parents. Lord Shiva and Goddess Parvati were amazed as to what happened. Then Lord Ganesha explained that his parents meant the world to him and that is all that mattered to him.
Lord Shiva and Goddess Parvati were awed by this answer and adjudged Lord Ganesha as the winner and proclaimed that when it came to worshipping the brothers, it would be Lord Ganesha who would be worshipped first. He also received the divine fruit which on consumption imparted him more wisdom and divine learning. Hence, Lord Ganesha is known to be very wise and his resourcefulness has earned him the moniker of being the one who can remove all obstacles.