כִּֽי־תֵצֵ֥א לַמִּלְחָמָ֖ה עַל־אֹיְבֶ֑יךָ וּנְתָנ֞וֹ יְהוָ֧ה אֱלֹהֶ֛יךָ בְּיָדֶ֖ךָ וְשָׁבִ֥יתָ שִׁבְיֽוֹ׃
אַז דו װעסט אַרױסגײן אין מלחמה אַקעגן דײַנע פֿײַנט, און ה׳ דײַן גאָט װעט זײ געבן אין דײַן האַנט, און װעסט פֿאַנגען פֿון זײ געפֿאַנגענע,
Mei HaShiloach
When you go out to war against your enemy etc and you take captives - that is the good that is found in the nation, since in every nation there is a force for good. And while that force is "among them" it is "in captivity", but when it comes "in Israel" then it is good in its completed form. And this good, while "among them" is "desire" since while it is found "among them" it is impermanent. Yet, when those who understand see that this desire will be missing, they need to make it enter "in Israel", since while the desire is "among them" it is "in captivity" - and since the force of desire comes from the Holy One of Blessing it is only appropriate to get it "in Israel."
Rashi
כי תצא למלחמה WHEN THOU GOEST FORTH TO WAR — Scripture is speaking here of a war that is not obligatory upon the Israelites (Sifrei Devarim 211:1), for in regard to a war that was waged against the inhabitants of Erez Israel, Scripture could not possibly say, “and thou hast captured captives”, since it has already been stated regarding them, (Deuteronomy 20:16) “[But of the cities of those people ...] you shall not allow any soul to live”.
Chizkuni
כי תצא, “when you go forth;” the introductory words of this paragraph are intended to teach that what follows are rules that apply only outside the boundaries of the Holy Land, and that they are not comparable to those that apply in the Holy land. The paragraphs that we have read prior to this, generally applied to conduct of Israelites in the Land of Israel.