Muhammad was illiterate so that leaves divine assistance. Scribes recorded his sayings on anything available to write on, usually scraps of papyrus but on wood if that was all they had where they were at the time. When it was decided to collect all of Mohammads sayings, they were searched for and gathered, with Caliphs deciding which of those fragments were actually things Mohammad said and that's where arguments started. Much of what Mohammad recited wasn't even written down until generations later because Mohammad didn't have a lot of scribes following him when he received his first vision at age 40. Some cousins began to believe him when he said he had/was having visions but not many of them were literate, either so very little was written at the time.
And it shouldn't matter if Mohammad was epileptic or not, other than as it relates to other ancient Prophets who seem to have been, too. Mohammad had visions and 'recited' things to the few scribes who followed him, so his physical condition doesn't make those visions any less valid, regardless of whether or not the Gabriel told Mohammad those things. I'm not Muslim, or follow any other organized religion, but I see a lot of truth in Mohammad's sayings and believe he was a 'vessel' through whom God helped spread the primary importance of love and following the Golden Rule. After all, that illiterate man did influence enough people at the time that they created a religion around him and made his sayings known worldwide 1,400 years later.