The oft-quoted general difference between Parashat Shofetim and Parashat Ki Teitzei is that the latter deals with individual Mitzvot, while the former deals with national Mitzvot, specifically with Mitzvot of war towards its end. The apparent transition from the Mitzvot of Parashat Shofetim to those of Ki Teitzei is the first section of Parashat Ki Teitzei, which describes the laws of the Eishet Yefat Toar. This section begins with the words “Ki Teitzei LaMilchamah,” “When you go out to war” (Devarim 21:10), which seems to place it within the section of the war Mitzvot of Perek 20. However, the last Mitzvah of Parashat Shofetim, Eglah Arufah, seems to not be related to war, thus creating a separation between the rest of the war Mitzvot of Perek 20 and Eishet Yefat Toar, found in the middle of Perek 21. Furthermore, the laws of Eishet Yefat Toar focus on one particular soldier’s family life, thus making it seem more akin to the upcoming family laws of Ki Teitzei (Bechor, Ben Soreir UMoreh, etc.).
Different Meforashim stress the two sides of this question. Rashi (s.v. VeLakachta Lecha LeIshah 21:11), quoting the Midrash Tanchuma (Ki Teitzei 1), connects the section to the family sections afterwards: if one marries an Eishet Yefat Toar, he will eventually hate her (alluding to the Bechor section), and she will give birth to a Ben Soreir UMoreh. Ibn Ezra (s.v. Ki Teitzei 21:10), on the other hand, views the section as the last in the string of war Mitzvot (he views Eglah Arufah as having been inserted into the string for a technical reason).
The answer to this question has essential implications in the understanding of why marrying the Eishet Yefat Toar is allowed. The classic explanation centers around, “Lo Dibrah Torah Ela Keneged Yeitzeir HaRa,” that the temptation for such a woman is so great, that had the Torah not permitted her, the soldier would have married her anyway. The motivation for the Torah’s permission is the futility of upholding the woman’s prohibited status – the soldier would disobey the prohibition – combined with the Torah’s desire for the soldier’s actions to be permitted. This motivation is essentially personal, focusing on the soldier’s own temptations, actions, and relationship to the Torah’s commandments; war is only the setting for the strong temptation. Thus, this explanation fits with the sections’ juxtaposition to the rest of Parashat Ki Teitzei.
If the section belongs to the string of war Mitzvot, on the other hand, war should be given a much more central place in the explanation of the Din. Indeed, the Midrash (Sifrei 211) posits that if Bnei Yisrael keep the laws of Eishet Yefat Toar, Hashem will help them win in war. This suggests that there might be a practical causative connection between Eishet Yefat Toar and victory in war. Perhaps “Lo Dibrah Torah Ela Keneged Yeitzeir HaRa” hints to the fact that the soldier’s temptation for the woman is so great, it will distract him from fighting the war, thus endangering all of Bnei Yisrael. The laws of Eishet Yefat Toar are a way of subduing the soldier’s temptation so that he can fight better; thus, keeping the Din of Eishet Yefat Toar will indeed help Bnei Yisrael win the war.
Rambam hints to this latter view of the Din. He categorizes Eishet Yefat Toar in his Mishneh Torah in the section of Hilchot Melachim UMilchamot (Perek 8), that deals with war Mitzvot. Furthermore, he explicitly compares it to the Din that soldiers behind enemy lines who are hungry and have nothing to eat but non-kosher food are allowed to eat the food. The simple explanation for this Din (for example, see Radbaz) is that the soldiers cannot search for Kosher food, as that would detract from fighting the war; in order to continue fighting with sufficient strength, they should eat the non-Kosher food. Rambam’s explicit comparison to Eishet Yefat Toar suggests that that too is an allowance of an otherwise prohibited action in order to remove distractions and help the war effort.
The Gemara (Kidushin 22a) presents Halachic support to the nationally-focused view of Eishet Yefat Toar. From the Torah’s command “VaHaveitah El Toch Beitecha,” that the soldier should bring the Eishet Yefat Toar into his house, the Gemara derives “SheLo Yilchatzenah BaMilchamah,” that the soldier should not “pressure her in the war.” The exact meaning of this phrase is unclear. Rabbeinu Tam (quoted in Tosafot) explains that Bi’ah is permitted once during the war, but the second Bi’ah must wait until after the entire process of Eishet Yefat Toar takes place at the soldier’s home. Thus, the soldier’s temptation is immediately subdued with one Bi’ah, and the Torah then stops him from having more (thus distracting him from the war) by making him wait until he gets home, after the war is over, after the danger to the rest of Bnei Yisrael’s soldiers has abated. Rashi explains “SheLo Yilchatzenah BaMilchamah” along the same lines, though he believes that even the first Bi’ah is prohibited during the war, so as not to distract the soldier at all from the war effort.
Rambam adds a new element to this view of Eishet Yefat Toar in his explanation of “SheLo Yilchatzenah BaMilchamah.” He rules that the soldier and Eishet Yefat Toar cannot have Bi’ah in the camp of the Israeli army; rather, he must take her to a clear place outside the camp. Perhaps this is because the soldier’s obsessive temptation with the Eishet Yefat Toar not only affects his ability to fight but also decreases the morale of his fellow soldiers. Thus, Rambam rules that the soldier should keep the matter private, so as not to hurt the war effort on the rest of the army’s part.