وما كان لنفس أن تموت إﻻ بٳذن الله كتابا موجﻼ
And no person can ever die except by Allah's leave and at an appointed term.
meaning, no one dies except by Allah's decision, after he has finished the term that Allah has destined for him. This is why Allah said,
كتابا موجﻼ
(at an appointed term) which is similar to His statements,
وما يعمر من معمر وﻻ ينقص من عمره إﻻ فى كتب
And no aged man is granted a length of life nor is a part cut off from his life, but it is in a Book. (35:11)
and,
هو الذى خلقكم من طين ثم قضى أجﻼ وأجل مسمى عنده
He it is Who has created you from clay, and then has decreed a (stated) term (for you to die). And there is with Him another determined term (for you to be resurrected). (6:2)
This Ayah (3:145) encourages cowards to participate in battle; for doing so, or avoiding battle neither decreases, nor increases the life term.
Ibn Abi Hatim narrated that,
Habib bin Suhban said that a Muslim man, Hujr bin Adi, said in a battle, "What prevents you from crossing this river (the Euphrates) to the enemy
وما كان لنفس أن تموت إﻻ بٳذن الله كتابا موجﻼ
(And no person can ever die except by Allah's leave and at an appointed term)."
He then crossed the river riding his horse, and when he did, the Muslims followed him. When the enemy saw them, they started shouting, "Diwan (Persian; crazy),'' and they ran away.
Allah said next,
ومن يرد ثواب الدنيا نوته منها ومن يرد ثواب اﻻخرة نوته منها
And whoever desires a reward in the world, We shall give him of it; and whoever desires a reward in the Hereafter, We shall give him thereof.
Therefore, the Ayah proclaims, whoever works for the sake of this life, will only earn what Allah decides he will earn. However, he will not have a share in the Hereafter. Whoever works for the sake of the Hereafter, Allah will give him a share in the Hereafter, along with what He decides for him in this life.
In similar statements, Allah said,
من كان يريد حرث اﻻخرة نزد له فى حرثه ومن كان يريد حرث الدنيا نوته منها وما له فى اﻻخرة من نصيب
Whosoever desires (by his deeds) the reward of the Hereafter, We give him increase in his reward, and whosoever desires the reward of this world (by his deeds), We give him thereof (what is decreed for him), and he has no portion in the Hereafter. (42:20)
and,
من كان يريد العجلة عجلنا له فيها ما نشاء لمن نريد ثم جعلنا له جهنم يصلها مذموما مدحورا
ومن أراد اﻻخرة وسعى لها سعيها وهو مومن فٲوليك كان سعيهم مشكورا
Whoever desires the quick-passing (transitory enjoyment of this world), We readily grant him what We will for whom We like. Then, afterwards, We have appointed for him Hell; he will burn therein disgraced and despised. And whoever desires the Hereafter and strives for it, with the necessary effort due for it while he is a believer, then such are the ones whose striving shall be appreciated. (17:18-19)
In this Ayah (3:145) Allah said,
وسنجزي الشاكرين
And We shall reward the grateful.
meaning, We shall award them with Our favor and mercy in this life and the Hereafter, according to the degree of their appreciation (of Allah) and their good deeds.
Allah then comforts the believers because of what they suffered in Uhud,