Ibn Qayyim al-Jawziyyah (d. 751) said:
An unpleasant situation does not occur to a servant except due to a sin, and Allāh pardons much more.
Allāh, the Most High, said (what means):
And whatever of misfortune befalls you, it is because of what your hands have earned. And He pardons much. [ash-Shūrá:30]¹
And He said to the best of His creation (after the prophets) and the companions of His prophet (what means):
(What is the matter with you?) When a single disaster smites you, although you smote (your enemies) with one twice as great, you say: “From where does this come to us?” Say (to them), “It is from yourselves (because of your evil deeds).” [Aal-e-Imrān:165]²³
And He said (what means):
Whatever of good reaches you, is from Allah, but whatever of evil befalls you, is from yourself. [An-Nisāʾ:79]⁴
And the meaning of good and evil here is blessings and afflictions which Allāh brings upon the servant.
Hence, all forms of deficiency, affliction and evil in the world and the hereafter is caused by sins and violating the commandments of the Lord.
There is no evil in the world except for sins and it’s causes.
Source: Madārij as-Sālikīn (1/423)
1. Muḥsin Khan and Hilālī
2. Ibid.
3. This is a succor from Allāh to His servants, the Muslims. When what afflicted them afflicted them on the day of ʾUḥud, and about seventy men among them were killed, Allāh said to them: Verily ﴾you have smote﴿ the disbelievers ﴾with one twice as great﴿ on the day of Badr, so you killed seventy men among their elders and you captured another seventy as slaves. So, the affair should be light and the (effect of the) affliction should be lessened on you, despite the fact that you and them are not equal. Because, your dead ones are in the Jannah and their dead ones are in the Fire. ﴾You say: “From where does this come”﴿ i.e from where did what afflicted and conquered us come? ﴾Say (to them), “It is from yourselves”﴿ when you disputed with one another and you disobeyed (the Prophet’s order) after He (Allāh) showed you what you loved (of booty and women). So return the blame to yourselves and beware of the means leading to destruction. [Tafsīr as-Saʿdī]
4. Muḥsin Khan and Hilālī