Sage Vyasa was meditating in the Himalayas. Lord Brahma appeared before him and asked him to write the Mahabharatham for the benefit of all. Sage Vyasa said that he could not compose the verse and write it down too and therefore asked for the help of someone wise, who would write down as he sang.
Brahma asked sage Vyasa to pray to Lord Ganesha to help him. Ganesha told Vyasa that he had enormous work to do and hence he would write it down, only if Vyasa was quick in singing it.
For his turn, Sage Vyasa requested that Ganesha should understand the meaning of the verse and only then put it down in writing.
Vyasa started singing. Whenever he felt Ganesha was writing too fast for him, he would come with a difficult verse, thus by the time Ganesha could decipher the meaning, he would have composed several more verses in his mind.
In this way, Vyasa completed the Bharatham in 60 lakhs granthams. This comprises the Kandapuranam, Ramayanam, Savithri Puranam, Nala Puranam and so on. Lord Ganesha wrote on Mount Meru using his tusk. Of these 60 lakh granthams, 30 lakhs are supposed to be in the Deva Logam, 15 lakhs in Yatcha Logam and 14 lakhs in Asura Logam. Only the remaining 1 lakh granthams is assumed to be on the earth.
Sage Vyasa is supposed to have sung 8,800 granthams, which were difficult for Ganesha to decipher. He has himself stated that Ganesha, Sage Vyasa himself and his Sugan are probably the only ones who know the meaning of those 8,800 granthams.
Mahabharatham is considered the fifth Veda.