According to Hindu tradition, Sage Vyasa composed the Mahabharata, and Lord Ganesha served as the scribe who wrote it down as Vyasa recited. The question asks 'Who wrote Mahabharata?' which in this context refers to the act of writing/transcribing, making Ganesha the correct answer. Vyasa was the composer/author, but Ganesha was the writer.