Praise be to Allah.
According to the Qur’an and Sunnah, there are two direct causes for calamities and trials, in addition to the wisdom of Allah, may He be exalted, in what He wills and decrees.
The first reason is:
Sins and acts of disobedience that the person has committed, whether they constitute kufr or are no more than regular sins or are major sins. Allah, may He be glorified and exalted, will test the one who committed them with calamity by way of requital and immediate punishment (i.e., in this world).
Allah, may He be glorified and exalted, says (interpretation of the meaning): “…but whatever of evil befalls you, is from yourself” [an-Nisa’ 4:79]. The commentators said: i.e., because of your sin.
And He, may He be glorified and exalted, says (interpretation of the meaning): “And whatever of misfortune befalls you, it is because of what your hands have earned. And He pardons much” [ash-Shoora 42:30].
End quote from Tafseer al-Qur’an al-‘Azeem, 2/363
It was narrated that Anas (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) said:
“If Allah wills good for His slave, He hastens his punishment in this world, and if He wills bad for His slave, He withholds from him (the punishment for) his sin, until He requites him for it on the Day of Resurrection.”
Narrated and classed as hasan by at-Tirmidhi (2396); classed as saheeh by al-Albaani in Saheeh at-Tirmidhi.
The second reason is:
That Allah, may He be exalted, wants to raise in status the patient believer, so He tests him with calamity so that he will bear it acceptance and patience, then He will be given the reward of those who are patient in the Hereafter, and will be recorded with Allah as one of the victorious. Calamities befell the Prophets and the righteous persistently, and Allah, may He be exalted, made it an honour for them by means of which they attained high status in Paradise. Hence it says in the saheeh hadeeth from the Prophet (blessings and peace of Allah be upon him): “If a certain status has previously been decreed by Allaah for a person, and he does not attain it by his deeds, Allaah afflicts him in his body or wealth or children.”
Narrated by Abu Dawood, 3090; classed as saheeh by al-Albaani in as-Silsilah as-Saheehah, no. 2599.
It was narrated from Anas ibn Maalik (may Allah be pleased with him) that the Prophet (blessings and peace of Allah be upon him) said: “Great reward comes with great trials. When Allah loves a people, He tests them, and whoever accepts it attains His pleasure, whereas whoever shows discontent with it incurs His wrath.”
Narrated and classed as hasan by at-Tirmidhi (2396); classed as saheeh by al-Albaani in as-Silsilah as-Saheehah, no. 146
The two reasons are mentioned together in the hadeeth of ‘Aa’ishah (may Allah be pleased with her), according to which the Prophet (blessings and peace of Allah be upon him) said: “Nothing befalls a believer, a (prick of a) thorn or more than that, but Allaah will raise him one degree in status thereby, or erase a bad deed.”
Narrated by al-Bukhaari (5641) and Muslim (2573).
Moreover, in most cases these two causes exist together rather than either of them occurring on its own.
Do you not see that if Allah tests a person with calamity because of his sin, and he bears it with patience and gratitude, Allah, may He be exalted, will forgive him his sin, raise him in status in Paradise and give him the reward of those who are patient and seek reward with Him?
When Allah tests a person with a calamity so that he will reach the lofty status that He has decreed for him in Paradise, his previous sins are expiated and it is regarded as requital for those sins in this world, so the requital will not be repeated for him in the Hereafter. This is what happened to some of the Messengers and Prophets, such as Adam (peace be upon him) and Yoonus (peace be upon him): Allah, may He be glorified and exalted, tested Adam with expulsion from Paradise, and He tested Yoonus ibn Matta with being swallowed into the belly of the fish. But by means of these tests, Allah raised them in status because of their patience and seeking reward with Him, may He be exalted. It was expiation for what each of them had done of going against His command (blessings and peace of Allah be upon both of them).
This proves that requital in this world is not separate from the requital in the Hereafter. These two reasons are mentioned together in many saheeh Prophetic hadeeths, such as that which was narrated by Sa‘d ibn Abi Waqqaas (may Allah be pleased with him) who said: I said: O Messenger of Allah, who among the people are most sorely tested? He said: “The Prophets, then the next best and the next best. A man will be tested according to his level of religious commitment. If his religious commitment is solid, his test will be more severe, but if there is any weakness in his religious commitment, he will be tested according to his level of religious commitment. And calamity will continue to befall a person until he walks on the earth with no sin on him.”
Narrated by at-Tirmidhi (2398) who said: (It is) hasan saheeh.
Nevertheless, one of these two reasons may be more apparent in some kinds of tests than the other. That may be understood by looking at the circumstances of the calamity.
If the one who is affected is a kaafir, then his calamity cannot be to raise him in status, because the kaafir will have no weight before Allah on the Day of Resurrection. But there may be a lesson and a reminder for others in that, not to do what he did. Or it may be an immediate punishment for him in this world, in addition to what is stored up for him in the Hereafter. Allah, may He be exalted, says (interpretation of the meaning):
“Is then He (Allah) Who takes charge (guards, maintains, provides, etc.) of every person and knows all that he has earned (like any other deities who know nothing)? Yet they ascribe partners to Allah. Say: "Name them! Is it that you will inform Him of something He knows not in the earth or is it (just) a show of false words." Nay! To those who disbelieve, their plotting is made fairseeming, and they have been hindered from the Right Path, and whom Allah sends astray, for him, there is no guide.
For them is a torment in the life of this world, and certainly, harder is the torment of the Hereafter. And they have no protector against Allah”
But if the one who is affected is a Muslim who commits sin openly or is a blatant evildoer, then it is most likely that he is being requited and punished with this calamity, because expiation of sins comes before raising in status, and the sinner is in greater need of expiation for his sins than of being raised in status.
On the other hand, if the Muslim is a devoted worshipper, obedient and righteous, and there is nothing between him and Allah but true ‘uboodiyyah (servitude), gratitude, praise, repentance and submission to Him, may He be glorified, then it is most likely that this calamity is a kind of honour and raising in status, and people are the witnesses of Allah on earth. If they know him to be righteous, then they may give him the glad tidings of raised status before Allah if he is patient in bearing the calamity.
But if the one who is affected shows displeasure and panic, then it cannot be thought that his calamity is an honour from Allah to raise him in status, because Allah, may He be glorified, knew that he would not be patient and accept it with contentment. So in this case it is most likely that it is a requital and punishment. One of the righteous said: The sign of calamity by way of punishment and requital is lack of patience when a calamity befalls, and panic and complaining to people. And the sign of calamity by way of expiation and erasing of sins is beautiful patience without complaining, panic or impatience, and lack of reluctance in fulfilling commands and doing acts of worship.
The sign of calamity by way of raising a person in status is contentment and acceptance, peace of mind, and patience in accepting the will of Allah until relief comes. End quote.
All of this is merely circumstantial evidence that one may ponder in order to learn something of the wisdom of Allah, may He be exalted, that is behind calamities and trials. But he cannot be certain as to which is the case with regard to himself or other people who are afflicted with calamities.
Perhaps it is more important than all of these details to note that the practical benefit that one should think about is that every calamity and test is good for him and will bring reward if he is patient and seeks reward with Allah, and that every test and calamity is bad for him if he panics and get angry. If he trains himself to bear calamities with patience and to be content with the decree of Allah, after that it will not matter if he knows the reason for the calamity or not. Rather it is always better for him to concern himself with his sins and shortcomings and to look for some mistake that he has committed, for all of us make mistakes. Who among us has not been negligent in his duties towards Allah, may He be exalted? If Allah, may He be glorified and exalted, caused the Muslims to suffer the calamity of many of them being killed on the day of Uhud, even though they were the Companions of the Prophet (blessings and peace of Allah be upon him) and the best of mankind after the Messengers and Prophets, because they had gone against the command of the Prophet (blessings and peace of Allah be upon him), then how can anyone think after that that he is entitled to be raised in status for anything that befalls him? When Ibraaheem ibn Adham (may Allah have mercy on him) saw strong winds and clouds building up in the sky, he would say: This is because of my sins; if I depart from among you, it will befall you.]
So how about us with all our shortcomings and sins?
And even more important than all of that is that one should always think positively of one’s Lord, in all situations, for whatever comes from Allah, may He be glorified and exalted, is good and He is the Protector of the pious and Oft-Forgiving.
We ask Allah, may He be exalted, to have mercy on us and forgive us, to teach us that which will benefit us and reward us for our calamities, for He is All-Hearing and answers prayers.
See also the answer to question no. 13205
And Allah knows best.