Whatever ill befalls you is a result of your sins. You have no one but yourself to blame for your misery. You sin and are punished for your sins. You want to lead a happy life? Then obey Allaah in what He has commanded you to do and refrain from that which He has forbidden you.
And whatever strikes you of disaster - it is for what your hands have earned; but He pardons much.
What comes to you of good is from Allah , but what comes to you of evil, [O man], is from yourself. And We have sent you, [O Muhammad], to the people as a messenger, and sufficient is Allah as Witness.
Abu Sa'id and abu Huraira reported that they heard Allah's Messenger (sallallaahu alayhi wa sallam) as saying:
Never a believer is stricken with discomfort, hardship or illness, grief or even with mental worry that his sins are not expiated for him.
[Sahih Muslim Hadiith No. 2573]