We have two proofs.
1) One is through hadith, which there are several from the imams of Ahlulbayt.
2) There is also a logical argument which is if the prophet forgets then he would forget the Quran or other things. It would not make sense for God who is perfect to send someone who either sins or forgets and makes mistakes. If a teacher forgets and makes mistakes several times the students will also make mistakes.