In The Name of Allaah, The Most Merciful, The Bestower of Mercy.
Allaah [The Exalted] said:
وَتَرَى ٱلشَّمۡسَ إِذَا طَلَعَت تَّزَٲوَرُ عَن كَهۡفِهِمۡ ذَاتَ ٱلۡيَمِينِ وَإِذَا غَرَبَت تَّقۡرِضُہُمۡ ذَاتَ ٱلشِّمَالِ وَهُمۡ فِى فَجۡوَةٍ۬ مِّنۡهُۚ ذَٲلِكَ مِنۡ ءَايَـٰتِ ٱللَّهِۗ مَن يَہۡدِ ٱللَّهُ فَهُوَ ٱلۡمُهۡتَدِۖ وَمَن يُضۡلِلۡ فَلَن تَجِدَ لَهُ ۥ وَلِيًّ۬ا مُّرۡشِدً۬ا
And you might have seen the sun, when it rose, declining to the right from their Cave, and when it set, turning away from them to the left, while they lay in the midst of the Cave. That is (one) of the Ayat (proofs, evidences, signs) of Allah. He whom Allah guides, is rightly guided; but he whom He sends astray, for him you will find no Wali (guiding friend) to lead him (to the right Path). [Surah Al-Kahf. Aayaat 17]
Allah protected them from the sun by facilitating for them a cave in which when the sun rose, it declined to the right away from it; and when it set, it turned away from it to the left; so its heat did not come into contact with them and thus harm their bodies; [وَهُمۡ فِى فَجۡوَةٍ۬ مِّنۡهُۚ – while they lay in the midst of the Cave]- Meaning, a spacious part of it, so that fresh air and breezes reaches them, stuffiness removed and not harmed by narrow space, especially that they were staying there for a prolonged period. This is one of Allaah’s Signs that demonstrates His Power, His mercy for them, and the fact that He responded to their supplications and guided them even in these affairs. So, this is why Allaah said: [مَن يَہۡدِ ٱللَّهُ فَهُوَ ٱلۡمُهۡتَدِۖ – He whom Allah guides, is rightly guided]- Meaning, there is no path to acquiring guidance except from Allah, because He is the One Who guides and directs a person to all the welfare in this life and the next. [وَمَن يُضۡلِلۡ فَلَن تَجِدَ لَهُ ۥ وَلِيًّ۬ا مُّرۡشِدً۬ا – but he whom He sends astray, for him you will find no Wali (guiding friend) to lead him (to the right Path)]- Meaning, neither will you find a guiding friend for him to look after him in a manner that will bring about welfare for him nor guide him to good and success. [An Excerpt from Tafseer As-Sadi. slightly paraphrased]