Exodus 21:20-21 KJV
And if a man smite his servant, or his maid, with a rod, and he die under his hand; he shall be surely punished.
Notwithstanding, if he continue a day or two, he shall not be punished: for he is his money.
Slavery is an abhorrent practice and this is, as I understand it, the earliest law protecting the slave of injustice. Still a person could wonder why God did not expressly forbid it. I offer a few explanations:
Had the Jews obeyed a law forbidding slavery, it would still have existed in other nations.
This series of laws would carry a message if humane treatment of others throughout the centuries and into differing cultures.
The sin nature would refuse obedience to God's command.
These laws bridle that nature if not killing it. Remember, these Old Testament laws are intended to bring us to Christ, the answer for the sin nature. The Old Testament could not and was not designed to cure the sin nature but to point us to the cure.
Man in his sin nature is a slave to Satan.
Slavery itself and these laws serve to depict the helpless state of the man who is without liberty in Christ.
I hate slavery and I am certain God does too. But slavery's existence in the world, then and now, is the result of man's rebellion against God. God's cure for slavery is to cure the rebellion. That is the thrust of the whole Bible. It serves to cure the disease and not merely some of the worst symptoms.