Short Answer: Mostly, he was thinking and meditating on the Greatness of God, and seeking to escape the social ills that dominated Meccan society at the time, including abuse and neglect of women, idolatry, an unfair balance of wealth, and abuse of those living in poverty. It was during such a time that God sent revelation to Muhammad, making him a Prophet.
Asalam Alaikum Abdulmajid,
Thank you for contacting About Islam with your question.
Prophet Muhammad, a Man of Thought
Prophet Muhammad (peace be upon him-PBUH) was known to be a reflective and pious man all his life.
Let’s read what the biographers of the life of the Prophet wrote about the early revelation:
When Prophet Muhammad was nearly forty he had been known to pass long hours in retirement meditating and speculating over all aspects of creation around him. This meditative temperament helped to widen the mental gap between him and his compatriots.
He used to provide himself with barley porridge and water and then directly head for the hills and ravines in the neighborhood of Makkah. One of these in particular was his favorite resort — a cave named Hira’, in the Mount An-Nur. It was only two miles from Makkah, a small cave four yards long and 1.75 yards wide.
He would always go there and invite wayfarers to share his modest provision. He used to devote most of his time, and Ramadan in particular, to worship and meditation on the universe around him.
His heart was restless about the moral evils and idolatry that were rampant among his people; he was as yet helpless because no definite course, or specific approach had been available for him to follow and rectify the ill practices around him.
This solitude attended with this sort of contemplative approach must be understood in its Divine perspective. It was a preliminary stage to the period of grave responsibilities that he was to shoulder very soon.
Privacy and detachment from the impurities of life were two indispensable prerequisites for the Prophet’s soul to come into close communion with the Unseen Power that lies behind all aspects of existence in this infinite universe. It was a rich period of privacy which lasted for three years and ushered in a new era, of indissoluble contact with that Power. (Saifur Rahman Al-Mubarakpuri, Ar-Raheeq Al-Makhtum)
Preparing for Responsibility of Prophethood
There are many hadiths concerning the life of Muhammad before becoming a prophet that show how Allah was preparing him for the great responsibility of prophethood.
As an infant, he was nursed by Halimah As-Sa`diyyah (may Allah be pleased with her) whose loving personality had a huge impact on him.
As a young boy, he became an orphan and was entrusted to the care of his grandfather, `Abdul Muttalib, who also showered love over the young Muhammad and even preferred him over his own children.
After his grandfather’s death, he was placed under the care of his loving uncle, Abu Talib.
Being an orphan himself made him keenly aware of the plight of orphans who must rely on the mercy of their relatives to survive and succeed in life. Muhammad was more fortunate than other orphans of his time, however.
As a young man he recognized many of the traditions of his people to be unjust.
The social conditions he grew up in favored the wealthy and those of high social status.
Women were considered to be the property of men, to be used and abused as they pleased.
The rights of the poor and powerless were trampled upon.
Not knowing how to change the society around him drove him to seek refuge in the Divine Creator for guidance.
Then He Received Revelation
The first form with which was started the revelation to the Messenger of Allah was the true vision in sleep. And he did not see any vision but it came like the bright gleam of dawn.
Thenceforth, solitude became dear to him and he used to seclude himself in the cave of Hira’, where he would engage in tahannuth (a worship for a number of nights) before returning to his family and getting provisions again for this purpose.
He would then return to Khadijah and take provisions for a like period, till the Truth came upon him while he was in the cave of Hira’. There came to him the angel and said: “Recite”. (Muslim)
The Arabic word “tahannuth“, mentioned above, is a form of worship that Muhammad used to practice before receiving revelation from Allah Almighty about prayers.
Linguistically, it means to follow the “hanifiyah” tradition, or the religion of Prophet Ibrahim.
During such times of worship and thought, the first revelations from Allah came to Muhammad while in the cave of Hira‘.
I hope this has been of assistance to you. Please keep in touch.
(From AboutIslam’s archives)