When the Prophet saw people severely tried, he made the supplication: "Praise be to [God] who has given me well-being such that I was not tried like these people. And He has preferred me over so much of his creation." Compassion for those in tribulation and gratitude for well-being is how the Prophet responded when he witnessed people in difficulty.
What comes to a person in his or her life may help a person move closer to God when the response is right. Ibn Abbas said that if a person is tested with a tribulation, he will find in it three blessings: first, the tribulation could have been worse; second, it was in worldly matters and not in spiritual ones; and third, it came in the finite world and not the infinite one. All three are reasons to thank God even for tribulations.
It is important to look at the life of the Prophet and know that no one faced greater tribulation. The Prophet lived to see all of his children buried, except for Fatima. How many people experience that in their lifetime? Out of six children, he saw five of them perish. His father died before his birth. His mother died when he was just a boy. His guardian grandfather then died. When he received his calling, he saw his people turn against him with vehemence and brutality. People who had once honoured him now slandered him, calling him a madman, liar, and sorcerer. They stalked him and threw stones at him until he bled. They boycotted him and composed stinging invectives against him. He lost his closest friends and relatives, like Hamza, who was killed on the battlefield. His beloved wife Khadija after 25 years of blissful marriage died during the Prophet's most difficult moment. Abu Talib, his protecting uncle, also died. The Prophet was the target of 13 assassination attempts. How many people have faced all of that? Not once in a single hadith is there a complaint from him—except when beseeching his Lord.
To be displeased with God's divine decree is to plunge into heedlessness (ghafla). Imam al-Qarafi distinguishes in his book al-Furuq the difference between a divine decree and being content with the decree itself. Should people be happy with all that comes their way, even the bad things? God has decreed that evil exist in the world in order to test humankind and for reasons that accord with His wisdom. We should not be displeased with His choice in allowing this. But when one sees societies plunged into immorality, it is not something to be pleased with or even feel indifferent. On the contrary, God requires that we dislike it. But never should we resent or be displeased with the fact that God has created a world wherein such things exist, however unpleasant they may be. As Ibn Abbas reminded, every trial could have been worse; it involved one's worldly affairs and not religion; and it came in this world and not the Hereafter, which lasts forever.
"Purification of the Heart" - Hamza Yusuf