R. Judah Zoldan on Bar-Ilan University's Parashat Hashavua Study Center:
The opening verses of this week’s reading deal with the possibility of marrying a beautiful woman taken captive in battle. The gemara (Kiddushin 21b) discusses the question of whether the priests, as well, are entitled to wed a beautiful captive woman, which tells us that priests participated in the battle. We can also deduce from what Parashat Shofetim says about exemptions from fighting in an optional war (Deut. 20:5-7) that the priests, including the high priest, used to go out to battle in optional wars (milhemet reshut): “Then the officials shall address the troops as follows: ‘… Is there anyone who has paid the bride-price for a wife, but who has not yet married her? Let him go back to his home, lest he die in battle and another marry her.’” According to the Mishnah (Sotah 8.3) not everyone who has paid the bride-price for a wife returns home: “The following may not return: … someone who is remarrying a woman he has divorced; the high priest, if he is marrying a widow; and regular priests, if they are marrying a divorcee or a haluzah (childless widow whose brother-in-law does not wish to marry her).See also this post.
However, it could be that a high priest who had become engaged to marry a widow, or a plain priest who had become engaged to a divorcee of haluzah, might be sent home from battle, although this would be for a different reason: he might fall into that category of those who are “afraid and disheartened.” “Rabbi Yose says: a high priest engaged to a widow, or a plain priest to a divorcee or haluzah … [who returns home, does so because] he is afraid and disheartened” (Mishnah Sotah 8.5). [Ed. Note: because such marriages are prohibited, priests who do so will be fearful of heavenly retribution.]
Commentators on Maimonides point to an ostensible contradiction in what he says regarding the participation of priests in battle.  Regarding a priest who wishes to marry a beautiful woman taken captive in battle, Maimonides ruled (Hilkhot Melakhim 8.4):A priest may have intercourse with a captive woman, since the Torah’s injunction was with reference to restraining one’s lust. However, he cannot marry her later, because she is a convert.Elsewhere Maimonides wrote (Hilkhot Shemitah ve-Yovel 13.12).Why did the Levites not share in the apportionment of land of Israel and its plunder, along with their brethren? Because they were set aside to worship the Lord and to minister to Him, and to instruct the masses in His proper ways and just laws, as it is said: “They shall teach Your laws to Jacob and Your instructions to Israel” (Deut. 33:10). Therefore they were set aside from the ways of the world: they do not go to war, as do the rest of Israel, they do not receive an apportionment of land as an inheritance, and they do not obtain things for themselves by the strength of their bodies; rather, they are the Lord’s host (Heb. hayil), as it is said: “Bless, O Lord, his substance (Heb. Barekh hashem helo),  and He, Blessed be He, provides for them, as it is said: “I am your portion and your share” (Num. 18:20).On the one hand, Maimonides ruled that a priest may marry a beautiful woman taken captive in war, from which we conclude that the priests did participate in battle; yet on the other hand he wrote that the Levites do not go to war. This contradiction can be resolved by the explanation that Rav Kook gives for the latter halakhah cited from Maimonides:“Go to war” – this means to fight private wars, such as when one tribe goes to war for the portion of land that it would thereby obtain. But when all of Israel go to war, they must fight as well. And fighting in a war that involves the generality of Israel is also a way of serving the Lord. For whoever is more specially set aside for worshipping the Lord has an even greater part in it [the war] than the rest of the people. When the Israelites entered the land, all the tribes were commanded to participate in the war of conquest, and tribes of Gad and Reuben were even given a special warning in this regard. At a certain point, after most of the country had been conquered, the tribes were allowed to settle in their territories provided that each tribe complete the conquest of its portion independently (Josh. 13). According to Rav Kook, the Levites were exempt from the tribal battles that were intended to complete the conquest, but in the battles of Israel as a whole they too participated...
 References may be found in Maimonides, Frankel edition, Hilkhot Melakhim 8.4. In addition, cf. Rabbi David Ha-Cohen, Megillat Milhamah ve-Shalom, Jerusalem 1968, pp. 27-28; Rabbi Judah Gershuni, “Al ha-Gevurot ve-al ha-Milhamot – Giyyus Kohanim u-Leviim le-Milhamah,” Tehumin 4 (1983), p. 62-63; Rabbi Jacob Ariel, “Yetziat Rav Tzevai le-Milhamah,” Sefer Harel, Hispin 2000, pp. 193-202.
 This verse is taken from the blessing that Moses gave to the tribe of Levi, and from it Maimonides deduced that the tribe of Levi are the Lord’s host and are exempt from going to war, as it is said: “Bless, O Lord, His host (helo)” (Deut. 33:11). Rashi interprets this to arrive at the opposite conclusion: “He saw that the Hasmoneans were destined to fight against the Greeks, and prayed for them, since they were few in number.” The Lord’s hayil is interpreted here as those who fight the Lord’s wars. Indeed, the Hasmoneans, who were priests, were the leaders in the battle against the Greeks.
 This comes from Rav Kook’s commentary on Maimonides, Hilkhot Shemitah ve-Yovel 12.13. Rav Kook wrote a book, Shabbat Ha-Aretz, in which he explained the laws of the sabbatical year as set forth by Maimonides in chapters 1-8. This book was published in 1910, in Rav Kook’s lifetime. In 1994, Makhon Ha-Torah ve-Ha’aretz, formerly of Kefar Darom (presently in Ashkelon), re- published this work in 2 volumes with sources, explanations, and an index. Rav Kook’s further explanations of chapters 9-13 of Maimonides are yet in manuscript. The explication of the halakhah which we cited here was published by Rabbi Moshe Tzvi Neri’ah in Tzav be-Kav, Kefar ha-Ro’eh 2004, p. 35.