The public men's room of a local park used to have a sign on the wall that said:
DO NOT FLUSH UNDERWEAR DOWN THESE TOILETS
It was obvious from that sign that someone had flushed underwear down those toilets. Or tried to. Maybe more than once.
Some laws can be written proactively. "Do not kill." "Do not steal." A little forethought suggests that these are good rules to have on the books.
Other laws are only written after the fact. "Don't flush your BVDs" is just such a rule. No one would think of outlawing the flushing of Y-fronts until someone actually tried to do it.
It is even likely that the first murder and the first theft occurred before these crimes were actually legislated against.
There will not be a king in Israel for a long time after the period in which Deuteronomy is set.
Deuteronomy 17:14-20 says that when Israel selects a king, that king must be God's chosen. He must not not have too many horses or too many wives. Foreign wives will lead the king into idolatry. Since these rules seem to address so specifically the cases of King Saul, who was not God's chosen, and King Solomon who had many horses and many foreign wives, I have to suspect that Deuteronomy was written only after Israel's united monarchy had fallen apart.
In fact, I think that Deuteronomy, or a version of it, was probably the scroll discovered in the temple during the reign of king Josiah (2 Kings 22). I'm just skeptical enough to entertain the idea that the scroll may even have been written for the occasion.
Chapter 18 also contains laws requiring the death penalty for idolatry, prohibitions against pagan divination practices, and a promise that, when Moses has died, YHWH will continue to speak to Israel through prophets.
Chapter 19 commands that three cities of refuge be established in Canaan, prohibits tampering with boundary markers, and establishes a rule that no one is to be found guilty at trial on the testimony of a single witness. Two or three witnesses are required. False witnesses will be punished according to the crime for which they accused an innocent person. Eye for eye, tooth for tooth, you know the drill.
Chapter 20 is about the conduct of warfare. Exemptions from military service are made for newlyweds, new householders, and cowards.
Before attacking a city, the Israelites are to offer terms of peace. If the offer is rejected, no quarter is to be given. All the men of the city are to be put to the sword. Women, children, livestock, and property can be taken as plunder. The cities of Canaan are an exception. Every living thing in them is to be killed. This is to keep the Israelites from being led into the worship of Canaan's idols.
Ancient cities were surrounded by walls for the protection of the inhabitants. Siege warfare, imprisoning the populace within its own city walls, was a brutal and effective strategy. Trees near a besieged city may be used to build siege ramps. Fruit trees are to be spared.
Next: Deuteronomy 21-23