39. A Book: the writ of destiny.
40. Here, “it” may be referring to the affliction as well as to the earth, or the self of man, or in view of the context, to all the creatures.
41. That is, it is not at all difficult for Allah to pre-ordain the destiny of each and every one of His creatures.
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.