Al-Anfaal • EN-AL-JALALAYN
﴿ مَا كَانَ لِنَبِىٍّ أَن يَكُونَ لَهُۥٓ أَسْرَىٰ حَتَّىٰ يُثْخِنَ فِى ٱلْأَرْضِ ۚ تُرِيدُونَ عَرَضَ ٱلدُّنْيَا وَٱللَّهُ يُرِيدُ ٱلْءَاخِرَةَ ۗ وَٱللَّهُ عَزِيزٌ حَكِيمٌۭ ﴾
“IT DOES NOT behove a prophet to keep captives unless he has battled strenuously on earth. You may desire the fleeting gains of this world-but God desires [for you the good of] the life to come: and God is almighty, wise.”
The following was revealed when they ransomed those taken captive at Badr It is not for any Prophet to have read as an takūna lahu or an yakūna lahu prisoners until he has made slaughter in the land going all the way in fighting disbelievers. You O believers desire the transient things of this world its ephemeral gains by ransoming while God desires for you the Hereafter that is its reward through your killing them; and God is Mighty Wise this was abrogated by His words and set them free afterward either with grace or by ransom Q. 474.