The Holy Quran is The Direct, Literal Word of God, and it was revealed to Prophet Muhammad (Peace and Blessings be upon him) through the Angel Gabriel. But how was The Quran written down if Prophet Muhammad (Peace and Blessings be upon him) was illiterate? Muslims believe that Angel Gabriel recited The Quran to Prophet Muhammad (Peace and Blessings be upon him), and the Prophet Muhammad (Peace and Blessings be upon him) recited The Quran to his companions, and his companions are the ones who wrote it down. Many companions wrote it down at once, making sure that the transmission of The Quran was recorded accurately between all of them and there were no differences or mistakes between them. There are also biographies about who these companions are, what they did, if they were trustworthy or not, etc.
And Allah Knows best.