I came to the Prophet ﷺ during his illness while he was suffering from a severe fever, and I said, "You are suffering from a very severe fever."I said, "That is because you have a double reward."He replied, "Yes. No Muslim is afflicted with any harm except that Allah causes his sins to fall away from him as the leaves fall from a tree."
أتيت النبي ﷺ في مرضه- وهو يوعك وعكا شديدا وقلت: إنك لتوعك وعكا شديدا. قلت: إن ذاك بأن لك أجرين. قال: أجل، ما من مسلم يصيبه أذى إلا حات الله عنه خطاياه كما تحات ورق الشجر.
Bukhari narrated it in the Book of Illness (5647), and Muslim in Righteousness and Maintaining Ties (2571), both from the hadith of Sufyan, from Amash, from Ibrahim Taymi, from Harith bin Suwayd, from Abdullah bin Masud, and he mentioned it. The wording given is Bukhari's. In another wording found in both, "Yes, I suffer from fever as two men among you would suffer."