All praise be to Allah and peace be upon the Messenger of Allah. I bear witness that there is no god but Allah alone who has no partner, and I bear witness that Muhammad is His Servant and Messenger.
Al Bukhari and Muslim reported in their Sahih on the authority of `Abdullah ibn `Umar ibn Al Khattab (may Allah be pleased with him) that he said: I heard the Messenger of Allah (peace be upon him) saying: "Three men from among those who were before you, set out together till they reached a cave at night and entered it. A big rock rolled down the mountain and closed the mouth of the cave. They said (to each other): Nothing could save you from this rock but to invoke Allah by giving reference to the righteous deed which you have done (for Allah's sake only).' So, one of them said: 'O Allah! I had old parents and I never provided my family (wife, children etc.) with milk before them. One day, by chance I was delayed, and I came late (at night) while they had slept. I milked the sheep for them and took the milk to them, but I found them sleeping. I disliked to provide my family with the milk before them. I waited for them and the bowl of milk was in my hand and I kept on waiting for them to get up till the day dawned. Then they got up and drank the milk. O Allah! If I did that for Your Sake only, please relieve us from our critical situation caused by this rock.' So, the rock shifted a little but they could not get out." The Prophet (peace be upon him) added: "The second man said: 'O Allah! I had a cousin who was the dearest of all people to me and I wanted to have sexual relations with her but she refused. Later she had a hard time in a famine year and she came to me and I gave her one-hundred-and-twenty Dinars on the condition that she would not resist my desire, and she agreed. When I was about to fulfill my desire, she said: It is illegal for you to outrage my chastity except by legitimate marriage. So, I thought it a sin to have sexual intercourse with her and left her though she was the dearest of all the people to me, and also I left the gold I had given her. O Allah! If I did that for Your Sake only, please relieve us from the present calamity.' So, the rock shifted a little more but still they could not get out from there." The Prophet (peace be upon him) added: "Then the third man said: 'O Allah! I employed few laborers and I paid them their wages with the exception of one man who did not take his wages and went away. I invested his wages and I got much property thereby. (Then after some time) he came and said to me: O Allah's slave! Pay me my wages. I said to him: All the camels, cows, sheep and slaves you see, are yours. He said: O Allah's slave! Don't mock at me. I said: I am not mocking at you. So, he took all the herd and drove them away and left nothing. O Allah! If I did that for Your Sake only, please relieve us from the present suffering.' So, that rock shifted completely and they got out walking.”
This Hadith contains many benefits and lessons:
First, the virtue of filial obedience and showing that it is one of the righteous actions by which hard troubles are removed. Allah (may He be Exalted) says: "And your Lord has decreed that you worship none but Him. And that you be dutiful to your parents." [Surat Al Isra': 23].
It was reported in Sahih Al Bukhari and Sahih Muslim on the authority of `Abdullah in Mas`ud (may Allah be pleased with him) who said: I asked the Prophet (peace be upon him): "Which deed is the dearest to Allah?" He replied, "To offer the prayers at their early stated fixed times." I asked, "What is the next (in goodness)?" He replied, "To be good and dutiful to your parents." I again asked: "What is the next (in goodness)?" He replied: "To participate in Jihad (religious fighting) in Allah's cause."
Second, the virtue of chastity and showing that if man abstains from adultery while he is able to commit it, that will be one of the best righteous actions. It was reported in Sahih Al Bukhari and Sahih Muslim on the authority of Abu Hurayrah (may Allah be pleased with him) that the Prophet (peace be upon him) said: "Allah will give shade to seven kinds of people on the Day when there will be no shade but His." and mentioned of them: A man who refuses the call of a charming woman of noble birth for an illegal sexual intercourse with her and says: I am afraid of Allah. 
Third, the Hadith also contains a proof to the virtue of honesty and perfection of actions because that man could conceal the money and gives the hired person his wage only, but his honesty and loyalty to his Muslim brother entailed that he would give him all the output of his money. Allah (may He be Exalted) says: "Those who are faithfully true to their Amanât (all the duties which Allâh has ordained, honesty, moral responsibility and trusts) and to their covenants." [Surat Al Mu'minun: 8].
Fourth, one of the causes which are used to remove hardships is invocation because Allah heard the invocation of those people and responded to them. Allah (may He be Exalted) says: "And when My Servants ask you (O Muhammad peace be upon him) concerning Me, then (answer them), I am indeed near (to them by My Knowledge). I respond to the invocations of the supplicant when he calls on Me (without any mediator or intercessor). So let them obey Me and believe in Me, so that they may be led aright." [Surat Al Baqarah: 186].
Fifth, sincerity is one of the causes of relieving afflictions because everyone of them said: “O Allah, if I did so for Your Sake, please relieve us from the present suffering."
Sixth, the permissibility of beseeching Allah with the righteous actions because each one of them besought Allah with his righteous actions to remove their hardship.
Praise be to Allah, the Lord of the worlds [i.e., people]. May Allah send His Peace and Blessings upon our Prophet Muhammad, his family, and all his Companions!
 423 - 424 No. 2272, and Sahih Muslim P. 1096 No. 2743.
 P. 121 No. 527, and Sahih Muslim 62 No. 85.
 P. 277 No. 1423, and Sahih Muslim P. 397 No. 1031.
Please write: COMMENT in this box to verify that you are human