God says in the Quran, “And We will most certainly try you with somewhat of fear and hunger and loss of property and lives and fruits; and give good news to the patient, Who, when a misfortune befalls them, say: Surely we are Allah's and to Him we shall surely return.” (Surah Al-Baqarah, verses 155-156)
These verses are known as verses of Istirja (return to Allah) and they teach us a very important lesson: That we should not grieve losing worldly things because all that we have and even we, ourselves, belong to God. One day He blesses us with something and another day sees it fit to take it away and in both cases, what He does is for our own good.
The fact that we all return to God after death reminds us of the fact that this world and our presence here do not last forever, and that whatever we are given or is taken away from us is only a means for us to move forward on the path toward perfection.
Knowing this and paying attention to it helps us greatly to enhance our patience.
According to Allameh Tabatabaei in Al-Mizan Exegesis of the Holy Quran, when man realizes that God is the owner of everything, he will never lament over difficulties, predicaments and losses because he does not consider himself to be in possession of anything to become happy or sad for gaining or losing them.
Hojat-ol-Islam Qara’ati writes in Noor Quran Exegesis: The patient ones do not resort to anyone but God when they face problems because in their view, the whole world is a classroom and a venue for examination in which we should learn and grow. This world is not a place to settle in and its difficulties do not mean that God is not kind to us. They are here to help us move faster and learn more. So bitter happenings and losses are also seen as sweet because they help our talents and aptitudes to flourish and also help us benefit from divine rewards.
Also, in times of difficulty remembering God and the fact that we all belong to Him and will return to Him has many blessings and good outcomes. It gives us consolation and help us better handle difficulties.
Of course this does not mean that we should not make efforts to tackle problems but what is important is changing how we look at problems. When facing difficulties, one may show impatience, another may remain patient, and another one may be both patient and thankful. Each of these approaches shows how much mindful we are of the reason why there are difficulties and problems in life.