The authorship of the core story is attributed to Krishna Dwaipayana or Vyasa, who often make several self referential appearances in the story.

Mythological sources say that, he dictated the story to lord Ganesha, the elephant faced Hindu god of good will, who put it into writing. At that time it was simply called jaya.

This may serve as a simplistic explanation. But it is possible that,
several sages may have a hand in writing the story.