salaam
also d Prophet (saw) went 2 d cave bcos of d atmosphere round him, d quraish wer worshippin stones, cheatin, stealin killin, mankind was in a mess man, so d Prophet (saw) used 2 go 2 cave hira & jus use 2 fink bout d terrible state dat humanity was in (u no dat sounded posh lol)
also Allah (swt) revealed d quran 2 him, Allah (swt) chose Muhammad (saw) ova all of d humanity, 2 guide us, from d start of his life d Prophet (saw) we know was goin 2 b guided 4 example - when he was small he was goin 2 go 2 d some carnival party thin wer der was a lot of alchohol & other un islamic stuff happenin, but on d way der he fell asleep & he didnt make it 2 d party, c Allah (swt) protected him from bad stuff - so obviosly fru Allah (swt) guidance RasoolAllah (saw) used 2 go 2 d cave so he cud b away from d bad atmosphere of d quraish & he chose 2 reveal d quran 2 him here in d cave!!. also d Prophet (saw) was seen sittin by a christian under a tree & d christian lad lol sed 2 him dat "no other den a Prophet, has sat under this tree", also in Makkah, he was known as Al Amin - the trustworthy, so it was in his character dat Allah (swt) wud choose him 2 reveal d quran 2. Allah (swt) wrote d quran, as he Allah (swt) says "dis quran wasnt sent down to you, to cause u misery, it was sent so mankind can reflect" - surah ta haa!
so Allah (swt) wrote d quran, n revealed it 2 d Prophet (saw)