Abu Musa reported the Prophet as saying, “No affliction great or small afflicts a man but for a sin, but there are more which God forgives.” Then he recited, “Whatever misfortune befalls you, it is because of what your hands have done; but He forgives much.”(Qur’an, xlii, 30)
‘Ali b. Zaid quoted Umayya as saying that she asked ‘A’isha about the words of God who is great and glorious, "Whether you publish what is in your minds or conceal it, God will call you to account for it,” ( Qur’an, ii, 284) and His words, "If anyone does evil he will be requited for it.”(Qur’an, iv, 123). She replied that no one had asked her about them since she had asked God’s messenger and received the reply, "This is God’s rebuke of His servant, by means of fever or misfortune with which He afflicts him, even such a matter as something he puts in his sleeve and grieves for when he loses it. The result is that the servant comes out of his sins as the pure gold comes out of the crucible."
‘Abdallah b. ‘Amr reported God’s messenger as saying, “When a servant of God is accustomed to worship Him in a good manner, then becomes ill, the angel who is entrusted with him is told to record for him actions equivalent to those which he did when he was well till God sets him free from his illness or takes him in death.”
‘Abdallah b. ‘Amr reported God’s messenger as saying, "When a man comes to visit an invalid he should say, ‘O God, cure Thy servant who may then wreak havoc on an enemy for Thy sake, or walk at a funeral for Thy sake’.”