Imam Ahmad recorded that Anas said, "The Prophet asked the people for their opinion about the prisoners of war of Badr, saying,
«إِنَّ اللهَ قَدْ أَمْكَنَكُمْ مِنْهُم»
(Allah has made you prevail above them.) `Umar bin Al-Khattab stood up and said, `O Allah's Messenger! Cut off their necks,' but the Prophet turned away from him. The Messenger of Allah ﷺ again asked,
(O people! Allah has made you prevail over them, and only yesterday, they were your brothers.) `Umar again stood up and said, `O Allah's Messenger! Cut off their necks.' The Prophet ignored him and asked the same question again and he repeated the same answer. Abu Bakr As-Siddiq stood up and said, `O Allah's Messenger! I think you should pardon them and set them free in return for ransom.' Thereupon the grief on the face of Allah's Messenger ﷺ vanished. He pardoned them and accepted ransom for their release. Allah, the Exalted and Most Honored, revealed this verse,
The second verse (68) is also a supplement to this admonition where it has been said that had it not been for a Divine writ already established, the course of action which you opted for - that of releasing the prisoners against ransom - would have brought upon you some grave punishment.
What is this writ and what does it mean? According to a narration from Sayyidna Abu Hurairah ؓ reported in Tirmidhi, the Holy Prophet ﷺ said: Spoils were not lawful for any community before you. When, on the occasion of Badr, Muslims went after collecting spoils - though, spoils were not made lawful for them until that time - this verse was revealed. It emphasized that this initiative taken by Muslims, before the injunction making spoils lawful for them was revealed, was a sin which deserved instant punishment. But, since the writ of Allah that spoils shall be made lawful for this community was already there in the Preserved Tablet, therefore, punishment was not sent over Muslims for this misconduct. (Mazhari)
It appears in Hadith narrations that, subsequent to the revelation of this verse, the Holy Prophet ﷺ said: The Divine punishment was almost about to descend when Allah, in His grace, held it back and had this punishment come, no one except ` Umar ibn al-Khattab and Sa'd ibn Mu` adh ؓ would have remained safe from it. This tells us that the cause of Divine admonition was the act of releasing prisoners against ransom - and, in the light of the narration from Tirmidhi mentioned earlier, the reason seems to be the act of collecting spoils. But, there appears to be no contradiction between the two. Taking ransom from prisoners is also nothing but a part of spoils.
Tazkirul Quran
Maulana Wahiduddin KhanOn ayahs 66–68
The reason for a lesser number of believers overcoming a large number of those who deny the truth has been explained by saying that the believers possessed fiqh, while those who deny the truth were devoid of it. The literal meaning of fiqh is understanding. This means the insight and wisdom which a man acquires as a result of faith. Faith in God is like the lighting of a lamp in a dark room. The lamp lights up the room in a such way that everything in it is seen clearly. Similarly, faith blesses man with a divine consciousness, after which he starts seeing all realities in their original shape. As a result of faith, man understands the reality of life and death. He comes to know that the most important thing is not the life of this world but the life of the Hereafter. This makes him fearless. He looks at death as if it is a door through which he may enter Paradise. A believer is God-fearing and he is anxious about the Hereafter. Such a temperament purifies him of all types of negative feelings. He rises above obstinacy, hatred, prejudice, revenge and haughtiness. The case of those who deny the truth is just the opposite. One who denies the truth acts emotionally, while the believer acts realistically. One who denies the truth carries out his dealings with narrow-mindedness, while the believer displays broad-mindedness.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.