57-Surah Al-Hadid ( The Iron ) 23
In order that you not despair over what has eluded you and not exult [in pride] over what He has given you. And Allah does not like everyone self-deluded and boastful –
لِّكَيْلَا تَأْسَوْا عَلَىٰ مَا فَاتَكُمْ وَلَا تَفْرَحُوا بِمَا آتَاكُمْ ۗ وَاللَّهُ لَا يُحِبُّ كُلَّ مُخْتَالٍ فَخُورٍ
Quran's Tafhim ( explanation)
*42) In order to understand why this has been said in that context, one should keep in mind the conditions through which the Muslims were passing at the time this Surah was revealed. 'An ever present danger of attack by the enemy, battles in quick succession, a state of constant siege, hardships caused by economic boycott by the disbelievers, persecution of the converts to Islam everywhere in Arabia, these were the conditions that the Muslims were confronted with at that time. The disbelievers looked upon these as a proof of the Muslims having been forsaken and rejected, and the hypocrites took these as a confirmation of their own suspicions and doubts. As for the sincere Muslims, they were facing these bravely and resolutely, yet the excess of hardship and suffering would sometimes become trying even for them. So, the Muslims are being consoled, as if to say: "No affliction, God forbid, has befallen you without the knowledge of your Lord. Whatever you are experiencing is according to the pre-ordained scheme of Allah, which is already recorded in the Writ of destiny. And you are being made to pass through these trials and tribulations for the sake of your own training for the great service that Allah wills to take from you. If you are made to attain to success without passing through these hardships, weaknesses will remain in your character due to which you will neither be able to digest power and authority nor withstand the tempests and furies of falsehood."