In this chapter, Moses gives the Israelites laws regarding the conduct of warfare.
This is a continuation on the 6th commandment, that you shall not murder. What this chapter shows is that the 6th commandment is not absolute and unequivocal. There are certain conditions where it is lawful to kill another man. In chapter 19, we saw it was lawful to kill murderers. In this chapter, we see it is lawful to kill others during warfare, provided the Israelites obey the conditions of this chapter.
This chapter has three sections. First is the disqualification of soldiers who have various reasons to not be fighting. Second is the conduct for Israel to maintain when they negotiate or attack other cities. Third is a small statement to avoid cutting down fruit trees.
In the beginning of the chapter, we are given an introduction to Israelite battle orders. While it doesn't really say anything about the arrangement or movement of troops, what it says is that "the priest" is supposed to encourage the people in their fight. This is another peculiar insertion of the priesthood into ordinary affairs. Originally the priesthood was created as an organization to handle the affairs of the tabernacle, but now we can see they are involved with enforcing many of the various parts of the covenantal law, such as ritual cleanliness (Lev 14) and in this warfare. The priest is truly a renaissance man; a doctor, priest, lawyer, military chaplain, scribe, accountant, etc.
The encouragement in this chapter is typical of ancient warfare, which I have already briefly discussed in relation to Deut 7 and Num 21. This chapter is quite similar; the priest is encouraging the men because morale failure is one of the chief causes of lost battles at the time. Biblical warfare usually involves a lot of shouting and trumpets and various displays primarily intended to encourage oneself and terrify one's foes into a rout. Think about it: if you have an army of 70,000 men, spaced over a mile long battlefield, you might only have 500 men on the frontline itself, so the proportional casualty rate is usually very low during an actual engagement. It is typically during a retreat that most casualties happen because the bulk of the army is more likely to get scared and flee than to actually engage in melee combat.
We see this later when officers are instructed to remove anyone who has a trembling heart "so that he might not make his brothers' hearts melt like his heart". It seems like such a shift from recent American wars like Vietnam where people had to go to great lengths to be disqualified from the draft. In Deuteronomy you just had to have a quaking heart and you were gladly removed. But then, as we saw in the division of the spoils (Num 31), the soldiers in a battle stand to benefit quite a bit from their involvement. Typically this can serve as a strong driver for involvement in the military, above and beyond any nationalistic ideals.
I don't believe the American army is allowed to pillage the countries it goes into for personal gain. But historically it is far more common for armies to pillage than not. In fact, in many cases soldiers would not even be paid wages for service; they simply pillaged the reward of their service from the towns and cities they conquered.
This leads to a very common phenomenon in history where large armies engender wars, because without a war to fight the army is essentially going unpaid, and the larger the army, the larger (or more numerous) the wars have to be. The modern world tends to have more professional, salaried armies so I don't believe this is as much the case today.
Anyway, there are three other conditions for discharge from the Israelite military: new houses, vineyards and wives. In all three cases the point is that of justice: it is unjust for a person to put effort into building something new and not reaping the rewards of that effort, at least for some time. Later in Deuteronomy we will see that time is one year. I think this is really interesting, because it seems to promote social stability for one thing, and for another it promotes building new infrastructure and families because the builder is (at least to the controllable extent) protected while reaping the benefits of what has been built.
The second section lays out the terms of warfare for Israel. It's very simple: nations within the bounds of the promised land must be destroyed without exception, including men, women, children and animals. Nations outside of the promised land should be negotiated with, and if they agree to serve Israel as "forced labor" then they may live, otherwise the men must die and everyone else is plunder (i.e. slaves). "Forced labor" is probably comparable to Israel's service in Egypt.
For many people this is a contentious passage, as it shows Moses (with God's approval) authorizing the Israelites to not only destroy all the Canaanites, but enslave other peoples outside of the promised land. The essentially criticism is that killing other people who have not threatened you is unjust. This is too large of an issue for me to respond comprehensively, so I will just list a few major points and move on.
Leaving aside that many nations in the promised land actually did threaten Israel (and in several cases engaged in pre-emptive wars against Israel, Ex 17), there are many answers to this criticism. First is the issue of progressive revelation, that different parts of the bible are intended to teach us specific aspects of God's character and that if we misread that part (for instance, studying one aspect when the author is trying to teach us a separate aspect), then we are likely to be mislead or deceived by our reading. In this case, the bible is trying to teach us about justice (retribution upon the Canaanites for their sins, cf. Gen 15:16) and the LORD's governance over warfare, his capability of guiding Israel and his power over nations far stronger than Israel. If we read this as "how the LORD treats foreigners", then we will be deceived. There are many places in the Law that emphasize honoring and respecting foreigners who enter the land of Israel, and that is the true and correct understanding.
Second, as I implied just now, Israel's invasion of the promised land is divine retribution for the sins of the Canaanites. The premise of the essential criticism above is that the people attacked by Israel are innocent victims, but that's simply not the case. A secondary part of this criticism is, "if Israel is justified in killing sinners, then what stops Christians from running around killing people today?" Among other things, this gets back to progressive revelation, that the meaning of following God has changed since the day of Moses. We have a fuller understanding than they did and we live in a different time and culture, largely for the better. We also have more tools available through our connection with the Holy Spirit, which makes physical warfare largely unnecessary. But never should we doubt that God has authority over the lives of all men, the authority to give life and the authority to take it.
The third thing to keep in mind is that this area is a hotbed of conflict (just as it is today). The Israelites have had to destroy two nations even to get to their destination in Canaan, and that's after navigating around several other nations they were not permitted to attack. At the crossroads between three continents, the Israelites will have to fight many wars in their future and I don't think it's reasonable to blame them for every conflict. In a sinful world, wars will happen, and this chapter provides guidance for how the Israelites are to handle those situations. That's all I will say on this topic.
Lastly, the Israelites are given a practical matter of not cutting down fruit trees when they are besieging a town, because sieges frequently drag out into starvation wars, with the (usually smaller) town garrison trying to starve out the (usually larger) army waiting outside, because armies generally cannot sustain themselves by throwing away their weapons and farming. Most of the time, the invading army is so large that a given area simply cannot grow enough food to sustain all the people in the army. It is only by moving around and stealing food stores from conquered towns that an army can feed itself. Maintaining fruit trees during a siege cannot sustain the army indefinitely, but could help sustain them for long enough to outlast the limited food supplies within the besieged town.