٤٢. إِذْ أَنتُم بِٱلْعُدْوَةِ ٱلدُّنْيَا وَهُم بِٱلْعُدْوَةِ ٱلْقُصْوَىٰ وَٱلرَّكْبُ أَسْفَلَ مِنكُمْ ۚ وَلَوْ تَوَاعَدتُّمْ لَٱخْتَلَفْتُمْ فِى ٱلْمِيعَـٰدِ ۙ وَلَـٰكِن لِّيَقْضِىَ ٱللَّهُ أَمْرًا كَانَ مَفْعُولًا لِّيَهْلِكَ مَنْ هَلَكَ عَنۢ بَيِّنَةٍ وَيَحْيَىٰ مَنْ حَىَّ عَنۢ بَيِّنَةٍ ۗ وَإِنَّ ٱللَّهَ لَسَمِيعٌ عَلِيمٌ
[42] Recall the time when you were on this side of the valley and they were encamped on the farther side and the caravan was below you (towards the coast). If you had made an engagement with them to fight, you would surely have evaded it (but there was a fight): so that Allah might accomplish what He had ordained, and that whoever had to perish should perish with a clear sign and whoever deserved to live, should live with a clear sign:34 indeed, Allah is All-Hearing, All Knowing.35
34That is, "It should be proved that whichever (Islam or ignorance) survived in the Battle, really deserved to live, and whichever perished, ought to have perished" . It should be noted that here the conflict for survival was not between different persons as such but between Islam and ignorance' as represented by the Believers and the disbelievers.
35As Allah hears everything and sees everything and knows everything, He is running His universe with wisdom and justice and will allow the right alone to survive.