These chapters of Deuteronomy have various miscellaneous laws, some about finding a dead body, and even about war brides and their treatment. It may seem odd to us, and some of it may even seem like common sense, but we have to remember that these people have been slaves for hundreds of years and have very little concept of how to run a society. They would do what the overseers said, or they’d be punished. Things like good and evil actions, or legal and illegal conduct, were foreign to the majority of these people.
There’s even what could be considered the first building code in 22:8 when Moses tells them to build parapet walls around the roof of their homes so that someone won’t fall from the roof and the blood be on the owner’s hands.
Also, you couldn’t even just look to the nations around you or the people you are going into the land to displace, because they were so evil that you are acting as the judgement of God upon them, so their scale of morality would be so far off that you couldn’t even adopt it and tweak it a little. They needed a society build from the ground up, and that’s something that usually takes centuries to evolve from tribal to feudal to national levels. This is all taking place in the span of a few decades.
Even the provisions for taking war brides sounds like something you wouldn’t expect to read in the Bible but it makes sense. If they treated them like all the other inhabitants of the land, any woman captured in war would face a fate worse than death. Filled with forced prostitution and slavery. But, if they were prevented from taking the women at all then they’d probably just end up dead like all the males in a captured city.
So this provision allows for a man to take a captive woman that pleases him, but he must shave her head and give her 30 days to mourn, and then take her as a wife. If it didn’t work out after that he was obliged to let her go free. He couldn’t just use her until he grew tired of her and then sell her like chattel slaves. It sounds harsh, but given the alternatives it was a better way.
Like many provisions regulating relations with the nations around them, how to conduct war, even divorcing your wife, it’s not the perfection that God wants from the people, but it’s a gradual growth. You couldn’t lay down the law with a toddler and expect the same level of adherence as you would an adult, and this is similar. The people are slowly introduced to morality and the goodness expected of them in emulation of the goodness of God, until it’s perfected by Jesus when he elevates the law to a new and higher level.
The common thread running through many of these rules, regulations and restrictions are that the people are expected to conduct themselves in a manner that is consistent with their call to be a chosen and special people. A shining city on a hill to bring honor to their God, who is so unlike the gods of the nations. They’re are to be fair and just to all.