Salmān Al-Fārsī – Allāh be pleased with him – once visited a sick friend. When he entered upon him he said:

Have glad tidings, for verily Allāh makes the illness of a believer an expiation [for his sins] and a cause of being pleased, whereas the illness of a sinner is like a camel that has been tied by its owners, then released by them: it knows not why it was tied up nor why it was released.

Al-Bukhārī, Al-Adab Al-Mufrad in the Chapter on the Expiation [of sins through] illness. Graded ṣaḥīḥ by Shaykh Al-Albānī in Ṣaḥīḥ Al-Adab Al-Mufrad.