The Messenger does not know the Unseen, and He cannot bring Benefit or Harm even to Himself
Allah
قل ﻻ أملك لنفسي نفعا وﻻ ضرا إﻻ ما شاء الله
Say : "I possess no power over benefit or harm to myself except as Allah wills.
Allah commanded His Prophet to entrust all matters to Him and to inform, about himself, that he does not know the unseen future, but he knows of it only what Allah informs him.
Allah said in another Ayah,
علم الغيب فﻼ يظهر على غيبه أحدا
(He Alone is) the All-Knower of the Ghayb (Unseen), and He reveals to none His Ghayb. (72:26)
ولو كنت أعلم الغيب ﻻستكثرت من الخير
If I had the knowledge of the Ghayb (Unseen), I should have secured for myself an abundance of wealth.
Ad-Dahhak reported that Ibn Abbas said that,
refers to money.
In another narration, Ibn Abbas commented,
"I would have knowledge of how much profit I would make with what I buy, and I would always sell what I would make profit from,
وما مسني السوء
("and no evil should have touched me).'' and poverty would never touch me.''
Ibn Jarir said,
"And others said, `This means that if I know the Unseen then I would prepare for the years of famine during the prosperous years, and in the time of high cost, I would have prepared for it.'''
Abdur-Rahman bin Zayd bin Aslam also commented on this Ayah;
وما مسني السوء
(and no evil should have touched me),
"I would have avoided and saved myself from any type of harm before it comes.''
The Prophet then stated that;
إن أنا إﻻ نذير وبشير لقوم يومنون
"I am but a warner, and a bringer of glad tidings unto people who believe.''
Allah tells that the Prophet is a warner and bearer of good news. He warns against the torment and brings good news of Paradise for the believers,
فٳنما يسرنه بلسانك لتبشر به المتقين وتنذر به قوما لدا
So We have made this (the Qur'an) easy on your tongue, only that you may give glad tidings to the pious, and warn with it the most quarrelsome of people. (19:97)