Short answer
He did not write it, and these rebukes are part of the proof. A man making up a scripture to win followers has every reason to leave out any blame of himself. Yet the Qur'an corrects the Prophet Muhammad (ﷺ) in words he had to recite to his own followers. It blames him for frowning at a blind man who came to learn. It asks why he forbade himself what God (﷾) had made lawful. It tells him the choice to forgive or punish certain men was not his. When revelation stopped for a time, he was mocked and could only wait. When the sun darkened on the day his son died, he would not let people call it a miracle. Islam's answer: the Qur'an is God's (﷾) word, and he passed it on as he received it, even where it corrects him.
Full explanation
He frowned at a blind man
A whole chapter of the Qur'an opens by blaming the Prophet (ﷺ). A blind man came to him asking to learn. The Prophet (ﷺ) was busy with the leaders of Mecca, and he frowned and turned away. The Qur'an records the frown and says the blind man was the one who deserved his attention. The Prophet (ﷺ) then recited those words aloud.
“(The Prophet) frowned and turned away, Because there came to him the blind man (interrupting). But what could tell thee but that perchance he might grow (in spiritual understanding)?- Or that he might receive admonition, and the teaching might profit him? As to one who regards Himself as self-sufficient, To him dost thou attend; Though it is no blame to thee if he grow not (in spiritual understanding). But as to him who came to thee striving earnestly, And with fear (in his heart), Of him wast thou unmindful.”
He forbade himself something lawful
The Prophet (ﷺ) swore off honey after one of his wives told him it left a bad smell. Two of his wives had agreed that whichever he visited would say this. Aisha, one of those two wives, reports the story. The Qur'an asked him why he forbade himself what God (﷾) had made lawful, and named his motive: to please them.
“O Prophet! Why holdest thou to be forbidden that which Allah has made lawful to thee? Thou seekest to please thy consorts. But Allah is Oft-Forgiving, Most Merciful.”
Aisha reports that the Prophet (ﷺ) used to drink honey at the house of his wife Zaynab bint Jahsh. Aisha and Hafsa agreed that whichever of them he visited would tell him he smelled of an unpleasant gum; one of them did, and he said he would never drink it again. Then the opening verses of Surat al-Tahrim were revealed, asking him why he forbade himself what Allah had made lawful.
The decision was not his
In the morning prayer the Prophet (ﷺ) asked God (﷾) to curse certain enemy leaders by name. The Qur'an told him the matter was not his. God (﷾) alone would decide whether to forgive them or punish them.
“Not for thee, (but for Allah), is the decision: Whether He turn in mercy to them, or punish them; for they are indeed wrong-doers.”
Abdullah ibn Umar reports that he heard the Prophet (ﷺ), in the morning prayer, ask Allah to curse certain named men. Then Allah revealed the verse telling him that the decision was not his.
When the revelation stopped
For a time no revelation came to the Prophet (ﷺ). A woman of Quraysh, the leading tribe of Mecca, mocked him that his devil had left him. He could do nothing to make it come. When it came, it answered her: his Lord had not forsaken him. A man composing the words himself could have ended that silence on the first day.
Jundab ibn Abdullah reports that Gabriel did not come to the Prophet (ﷺ) for a time, and a woman of Quraysh mocked him, saying his devil had left him. Then the opening verses of Surat al-Duha were revealed: his Lord had not forsaken him.
“By the Glorious Morning Light, And by the Night when it is still,- Thy Guardian-Lord hath not forsaken thee, nor is He displeased.”
The miracle he turned down
The infant son of the Prophet (ﷺ), Ibrahim, died on the day of an eclipse, when the sun goes dark. The people said the sun had darkened for him. A man inventing a religion would have let them believe it. He corrected them: the sun and moon do not eclipse for anyone's death or birth.
Al-Mughira ibn Shu'ba reports that the sun eclipsed on the day the Prophet's (ﷺ) son Ibrahim died, and people said it had eclipsed because of Ibrahim's death. The Prophet said that the sun and the moon do not eclipse for the death or the birth of anyone, and told them to pray and call on Allah when they see an eclipse.
Even how he recited was corrected
The Qur'an also tells the Prophet (ﷺ) how to receive it. He used to move his lips quickly to hold on to each new verse. He was told not to hurry. Collecting and reciting it was God's (﷾) task, and his was to follow. The command "Say" comes more than three hundred times, telling him what to say. God (﷾) speaks in the first person: "Verily, I am Allah". The book speaks to him. It does not speak for him.
“Move not thy tongue concerning the (Qur'an) to make haste therewith. It is for Us to collect it and to promulgate it: But when We have promulgated it, follow thou its recital (as promulgated): Nay more, it is for Us to explain it (and make it clear):”
Ibn Abbas explains that the Prophet (ﷺ) used to find the revelation heavy and would move his lips quickly with it, until Allah revealed that he should not hurry his tongue: gathering and reciting the Qur'an was Allah's task. After that he listened while Gabriel recited, and then recited it as Gabriel had.
“Verily, I am Allah: There is no god but I: So serve thou Me (only), and establish regular prayer for celebrating My praise.”
The objection and the answer
Qur'an 80:1-10 — Surat 'Abasa (He frowned), verses 1-10
“(The Prophet) frowned and turned away, Because there came to him the blind man (interrupting). But what could tell thee but that perchance he might grow (in spiritual understanding)?- Or that he might receive admonition, and the teaching might profit him? As to one who regards Himself as self-sufficient, To him dost thou attend; Though it is no blame to thee if he grow not (in spiritual understanding). But as to him who came to thee striving earnestly, And with fear (in his heart), Of him wast thou unmindful.”
Cited for
An author can write rebukes of himself to look honest, or because his own conscience changed. So the rebukes do not show a source outside him.
The response
An author might add a small fault to look humble. The frown is recorded in words he had to recite to his own followers. But the strongest signs are not texts at all. He could not bring revelation when his conscience moved him. When it stopped, he was mocked and could only wait, and a man composing the words could have ended that on the first day. When people called the eclipse a miracle for his son, he turned the honour down.
Where it lands — The pause and the eclipse were not words he could compose, and both cost him. That fits a messenger passing on what he was given, not an author polishing his image.
Perspectives
The Islamic perspective
The Qur'an is the word of God (﷾), given to the Prophet (ﷺ) through the angel Gabriel. He passed it on as he received it, including the verses that correct him. That is what an honest messenger does, and a forger does not.
The Qur'an blames the Prophet (ﷺ) for frowning and turning away from a blind man who came to learn.
The Qur'an asks the Prophet (ﷺ) why he forbade himself what God (﷾) made lawful, to please his wives. His wife Aisha reports the occasion.
The Prophet (ﷺ) prayed against certain men. The Qur'an tells him that the decision to forgive or punish them was not his.
Revelation stopped for a time, and the Prophet (ﷺ) was mocked for it. The answer came only when the revelation resumed.
When people said the sun eclipsed for his son's death, the Prophet (ﷺ) denied it instead of accepting the honour.
A man inventing a scripture would not put public rebukes of himself into a text he must recite to his followers. So these verses point to a source outside him.
The Qur'an is the word of God (﷾), which the Prophet (ﷺ) received and passed on without adding to it.