Abu Sa’eed al-Khudree (RA) reported that the Prophet (SAW) said:

Muslim is not afflicted by hardship, sickness, sadness, worry, harm, or
depression - even if pricked by a thorn, but Allah expiates his sins
because of that.' [Bukhari and Muslim]

‘Aishah (RA) narrated that once some pain afflicted the Prophet(SAW) causing him to suffer and turn about in his bed. she said: ‘Had one of us done this, you would have blamed him.’
He (SAW) replied: ‘ An ailment is intensified for the righteous. whenever a
believer is afflicted by a hardship, whether it is a thorn or more, a
sin is taken off from him because of it, and he is elevated by one rank
(in Jannah). ‘ [Ahmad]

Anas (RA) reported that the Prophet (SAW) said: ‘ The amount of reward is in accordance with the amount of suffering. When Allah (SWT) loves some people, He tries them (with affliction). He who then is content (with Allah’s decree) has achieved The acceptance (of Allah), and he who is dissatisfied (with Allah’s decree) will attain the anger (of Allah).’ [Tirmidhi]

Anas (RA) reported that the Prophet (SAW)
said: ‘ When Allah wills good for a servant of His, He expedites his
punishment in this life; and when He wills retribution for a servant of
His, He holds his sins for Him to judge him by them on the Day of
Resurrection.’ [Tirmidhi]

Abu Hurayrah (RA) reported that the Prophet (SAW) said:

‘ Whenever Allah wills good for a person, He subjects him to adversity’[Bukhari and others]

Abu Hurayrah(ra) reported that the Prophet(SAW)
said: ‘ Hardships continue to befall a believing man and woman in their
body, family, and property, until they meet Allah burdened with no
sins. ‘ [Tirmidhi]