And when We cause mankind to taste of mercy, they rejoice therein; but when some evil afflicts them because of what their hands have sent forth, behold, they are in despair!
This is a denunciation of man for the way he is, except for those whom Allah protects and helps, for when man is given blessings, he is proud, and says:
ذَهَبَ السَّيِّيَاتُ عَنِّي إِنَّهُ لَفَرِحٌ فَخُورٌ
"Ills have departed from me." Surely, he is exultant, and boastful. (11:10)
He rejoices over himself and boasts to others, but when difficulties befall him, He despairs of ever having anything good again.
Allah says:
إِلاَّ الَّذِينَ صَبَرُواْ وَعَمِلُواْ الصَّـلِحَاتِ
Except those who show patience and do righteous good deeds.
They are patient during times of difficulty and do good deeds at times of ease.
It was reported in the Sahih:
عَجَبًا لِلْمُوْمِنِ لاَ يَقْضِي اللهُ لَهُ قَضَاءً إِلاَّ كَانَ خَيْرًا لَهُ إِنْ أَصَابَتْهُ سَرَّاءُ شَكَرَ فَكَانَ خَيْرًا لَهُ وَإِنْ أَصَابَتْهُ ضَرَّاءُ صَبَرَ فَكَانَ خَيْرًا لَه
How wonderful is the affair of the believer. Allah does not decree anything for him but it is good for him. If good things happen to him, he gives thanks, and that is good for him; and if bad things happen to him, he bears that with patience, and that is good for him.