The Holy Quran correctly answered the test questions put forward to the Prophet Muhammad PBUH. These questions were often asked by skeptics and disbelievers to test his prophethood. For example, Surah Kahaf answered the following three questions which the pagans of Makkah, in consultation with the people of the Book, had put to the Holy Prophet to test him:
1. Who were the Sleepers of the Cave?
2. What is the real story of Khidr?
3. What do you know about Zul-Qarnain (Cyrus the Great)? 9
These three questions and the stories involved concerned the history of the Christians and the Jews were not known to the Arabs of the Prophet’s time. Therefore, a choice of these questions was made to test whether the Holy Prophet PBUH possessed any source of knowledge of the hidden and unseen things. Allah SWT, however, not only provided complete answers to their questions but also employed the three stories to the disadvantage of the opponents of Islam in the conflict that was going on at that time at Makkah between Islam and unbelievers.
The questioners were told that "the Sleepers of the Cave" believed in the same doctrine of Tauhid which was being put forward in the Holy Quran and that their condition was similar to the condition of the persecuted Muslims of Makkah. On the other hand, the persecutors of the Sleepers of the Cave had behaved in the same way towards them as the disbelievers of the Quraish were behaving towards the Muslims. Besides this, the Muslims were taught that even if a believer is persecuted by a cruel society, he should not bow down before falsehood but emigrate from the place all alone, if need be, with trust in God. Incidentally, the disbelievers of Makkah were told that the story of the Sleepers of the Cave was clear proof of the creed of the Hereafter, for this showed that Allah SWT has the power to resurrect anyone He wills even after a long sleep of death as He did in case of the Sleepers of the Cave.
The story of the “Sleepers of the Cave” has also been used by the Holy Quran to warn the chiefs of Makkah who were persecuting the small newly formed Muslim Community. Concurrently, Prophet Muhammad PBUH was instructed never to compromise with the persecutors, however, influential and powerful they’d be. The chiefs of Makkah were admonished not to be puffed up with the transitory life of pleasure they were enjoying.
The story of Khidr and Prophet Musa AS (Moses) was related by the Holy Quran to provide the answer to the question of the disbelievers and to give comfort to the believers as well. The story teaches us to have complete faith in the wisdom of God and to acknowledge our incompetence in completely comprehending the circumstances and incidents around us. Something appearing negative to us may benefit us in ways unknown to us and vice versa.
The same is true of the story of Zul-Qarnain (Cyrus) for it also admonishes the questioners, as if to say, "O you vain chiefs of Makkah you should learn a lesson from Zul-Qarnain. Though he was a great ruler, a great conqueror, and the owner of great resources, he always surrendered to his Creator, whereas you are rebelling against Him even though you are insignificant chieftains in comparison with him.”
In short, the Holy Quran turned the tables on the questioners who had tried to "expose" Prophet Muhammad PBUH by asking these difficult questions unknown to the Arabs. The disbelievers did not expect the answers to these questions from Prophet Muhammad PBUH. However, the Holy Quran being the word of Allah SWT provided the correct answers again authenticating that verily Allah SWT is All-Knowing and All-Powerful.