Shiva put a condition before both of them: whoever can travel to the ends of the earth and come back be will be considered more intelligent( various interpretations here, like getting married, some fruit etc)
Kartikeya immediately set out on his journey. His vehicle was a peacock.
Three years passed and still he had not reached the ends of the earth. Meanwhile,
the pot-bellied Ganesha stayed at home enjoying himself. He knew that he
could not hope to keep up with his athletic brother.
When Shiva saw that Ganesha had not even begun the race, he said to his son,
What are you doing? You have not yet even started! Any day, any moment,
Kartikeya will come back. What is wrong with you?
Ganesha remained silent and Shiva continued, I know what you are thinking.
As long as you can get married, it is enough. You no longer care who is first
and who is second. That is why you are not in a rush. You have accepted your
defeat.
Ganesha simply smiled at his father and went on with his usual routines.
One day, a thought crossed his mind: I am sure that by now my brother has
travelled to the farthest lengths of the earth and is on his way home. Now
is the time for me to act.
He went to bathe in the river and then circled his mother, Parvati. After
completing one round, he bathed once more and again circled his mother. Seven
times he bathed and seven times he circumnavigated her.<br>
What are you doing, my son? asked Parvati.
Have you not read our sacred scriptures, Mother? Ganesha answered. The
shastras tell us that you are the Divine Mother; you are the whole world,
the entire universe. I went around you not once but seven times. That means
I have gone around the world seven times. So am I not more intelligent?
What kind of logic is this? objected Shiva.
Ganesha presented his argument: If you do not consider my mother to be the
Divine Mother, if you do not believe in the Vedas, then why do you tell people
to honour the Vedas? You always say that the Vedas are correct and perfect.
How can you justify yourself?
Shiva realised that his son was right. Parvati was the entire universe.
Hence, till date, Ganesh is consider the God of intelligence and education.....