Surah Al-Anfaal

8:67

مَا كَانَ لِنَبِىٍّ أَن يَكُونَ لَهُۥٓ أَسْرَىٰ حَتَّىٰ يُثْخِنَ فِى ٱلْأَرْضِ ۚ تُرِيدُونَ عَرَضَ ٱلدُّنْيَا وَٱللَّهُ يُرِيدُ ٱلْءَاخِرَةَ ۗ وَٱللَّهُ عَزِيزٌ حَكِيمٌۭ

It is not for a prophet to have captives [of war] until he inflicts a massacre [upon Allah 's enemies] in the land. Some Muslims desire the commodities of this world, but Allah desires [for you] the Hereafter. And Allah is Exalted in Might and Wise.

Tafsir 8:67

It is not right for a prophet to take captives from the disbelievers who fight against him until he kills many of them, so that this makes other disbelievers fear fighting him. By taking captives from Badr, O believers, you want to receive ransom, but Allah wants the Afterlife for you, which is gained by making religion victorious and powerful. Allah is Mighty in His essence, His attributes and in His domination. Nothing can overcome Him. He is Wise in His decree and sacred laws.