Is Clinging to the Religion a Cause for Affliction
Answering the question: Is it permissible to say that the cause of one's affliction was due to him clinging to the commandments of the Religion?
As for the person who says that the cause for such affliction is due to being firm and steadfast upon the Religion - then such a person is ignorant.
Shaykh ʿAbd al-ʿAzīz ibn ʿAbdullāh ibn Bāz
[Q]: There was a person in our city who was very firm in practicing the Religion, and was later afflicted with an illness. Some of the people started saying to him that the cause of him being afflicted with this illness is because of his adhering to the Religion. Being affected with this type of talk, the person then shaved off his beard and he neglected his Prayers. So is it permissible to say that the cause of his affliction was due to him clinging to the commandments of the Religion? And the one who says such a thing, is he considered a kāfir(disbeliever) because of such a saying?
[A]: “Clinging on to the Religion is not a cause for his illness. Rather, it is a cause for every good, both in this life and in the Hereafter. And it is not permissible for any Muslim, that when some foolish and ignorant people utter words such as this, to give them any weight. Nor is it permissible to shave one's beard or shorten it, or neglect guarding the five obligatory Prayers in congregation. Rather, it is obligatory for such a person to remain steadfast upon the truth, and to keep away from all that Allāh has prohibited, and to beware of all that which angers Allāh and incurs His punishment - by obeying Allāh and His Messenger (ṣallallāhu ʿalayhi wa-sallam), Allāh - the One free from all defects said:
“Whosoever obeys Allāh and His Messenger will be admitted into Gardens of Paradise, beneath which rivers flow, to dwell therein forever. That will be the greatest achievement. But whosoever disobeys Allāh and His Messenger and oversteps His limits, Allāh will cast him in the Fire, to abide therein; and he shall have a humiliating punishment.”
[Sūrah al-Nisāʾ 4:13-14]
And Allāh - the Mighty and Majestic - said:
“Whosoever has taqwá (piety, fear and obedience) of Allāh, He will make a way out for him. And He will provide for him from places he could never imagine.”
[Sūrah al-Ṭalāq 65:2-3]
And He - the Most Perfect - said:
“Whosoever has taqwá of Allāh, He will make his affair easy for him"
[Sūrah al-Ṭalāq 65:4]
And the verses with this meaning are plentiful.
As for the person who says that the cause for such affliction is due to being firm and steadfast upon the Religion - then such a person is ignorant. It is obligatory to censure such a person and to know that clinging to the Religion does not bring about anything except good. As for what occurs to a Muslim by way of a calamity that he dislikes, then this is a form of expiating his evil actions and a forgiveness for his sins. As regards to the issue of takfīr (declaring a Muslim to be a kāfir, (disbeliever) upon this person, then this requires detail, and is known from the chapters concerning the judgement upon a murtad(apostate) - which can be found in the books of Islamic jurisprudence and understanding. And with Allāh is the power and ability.” 
 Majmūʿ al-Fatāwá wa Maqālāt al-Mutanawwiʿah (1/32-33)