You have provided justification for any of my points, just apologetics
EX 21:20-21 says that with the Lord's approval, a slave may be beaten to death with no punishment for the perpetrator as long as the slave doesn't die too quickly
2 Samuel 8:13 says David slew 18,000 Edomites and made the rest slaves.
Numbers 31:9 states that following the Lord's command, Moses orders the Israelites to kill all the Midianite male children and every woman who has known man. How it was determined which women had known men? One can only speculate.
Judges 21:10-12 says Go and smite the inhabitants of Jabesh-gilead with the edge of the sword and; also the women and little ones.... every male and every woman that has lain with a male you shall utterly destroy." Again, how did they know? Did god god "kill her, bit not that one because she is a virgin?" Or was it determined by physical examination?
However it was determined they so find four hundred young virgins whom they bring back for their own use... I.e. sex slavery
Chapter 21of Judges is part of the internal strife in ancient Israel.
I find the word ' wives ' (Not slaves) at Judges 21:14; Judges 21:18; Judges 21:22-23.
Those people (Jabesh-Gilead Joshua 9:3-27) had No harm come to them - Joshua 3:15; Joshua 3:18
Besides long-term slaves, there were in ancient Israel short-term slaves to pay off one's debt (No debtor's jail in ancient Israel) The Jubilee Year gave early freedom from debt - Exodus 21:2; Leviticus 25:10,13, 39-40.
Continuing at Exodus 21:26-27 if a master mistreats, then the slave was No longer a slave but set free.
There was penalty (punishment ) for bodily injury as per Exodus 21:22-25.
In ancient Israel there was the ' avenger of blood '.
In the King James at Exodus 21:20 says ' surely punished ' instead of from the Hebrew 'must be avenged'.
In the Hebrew at Exodus 21:20 it is talking about the killing of a slave that he shall surely be 'avenged' .
So, the 'avenger of blood ' could legally take the life of the person doing the killing as per Leviticus 24:17.
At 2 Samuel 8:13-14 I don't see the word slaves but as 'servants'.
In verse 13, I read Syrians there. In verse 14 about Edom.
At Numbers 31:9 mentions women and their minor children as captives.
At Numbers 31:16-17 mentions because of the matter of Pe'or there was a 'plague'. (venereal disease?)
That could be because there was immoral worship connected to the worship of the Baal of Pe'or.
Thus, to spare those with the plague could have spread to Israel.
The rest of them could have their lives spared.