Praise be to Allah, and may peace and blessings be upon the Messenger of Allah. To proceed:
If the question is asked as an objection to the decree of Allah, the Muslim must understand that the wisdom of Allah تعالى is far greater than human minds can comprehend, and that he must submit to His decree and predestination. Allah تعالى says: “And you have not been given of knowledge except a little.” [Al-Isra: 85]
But if the question is asked in order to understand the wisdom, then the trials of a believer may have great benefits, including:
Testing the sincerity of faith: A sincere believer remains patient during affliction, seeks reward from Allah, and knows that what has befallen him is by the decree of Allah. Thus, his faith and steadfastness increase.
Attaining the rank of those who are patient: Allah تعالى has praised those who are patient and promised them a tremendous reward. He سبحانه says: “Indeed, those who are patient will be given their reward without measure.” [Az-Zumar: 10] Therefore, Allah may test a believer so that, through this calamity, he may attain the rank of patience and the great reward it contains.
Moving on to greater bliss: A believer may suffer in this world and then, after his death, move to the bliss of the Hereafter. Thus, he leaves the abode of suffering for the abode of bliss, and his joy in what Allah has prepared for him will be greater.
As for what sinners and disbelievers are given of health, provision, and worldly enjoyment, this is not evidence that Allah is pleased with them or that they are honored by Him. Rather, it may be a form of respite and gradual enticement for them. Allah تعالى says: “You exhausted your pleasures during your worldly life and enjoyed them; so today you will be recompensed with the humiliating punishment.” [Al-Ahqaf: 20]
The Prophet ﷺ also said: “The world is a prison for the believer and a paradise for the disbeliever.” Narrated by Muslim.
Therefore, it is not correct to measure a person's status with Allah by the health, wealth, or comfort he possesses in this world. Affliction may, in the case of a believer, be goodness, elevation in rank, and reward, while apparent prosperity in the case of a sinner may be respite and gradual enticement.
And Allah تعالى knows best.