The ideal expressed in the Bible is that men should make their living as independent yeomen such as pastoralists or the equivalent and women should support them. However, the reality is that at many times and places this is not possible. Not everyone is capable of that level of independence and there are often not enough resources to go around. Hence there needs to be a way for people who can’t provide for themselves to be looked after. One such way is slavery. The slaves do useful work for the master and in exchange the master keeps the slaves in line and provides for them, often to a greater degree than they are worth due to familiarity and pride of ownership. The Bible sought to regulate slavery so that everything was fair and above board.
But, you say, the Bible must be evil because slavery is wrong. Why is it wrong? Because people should live as they choose. Most people don’t get to live as they choose and when they do the results are often a disaster. Because it is an imposition by force. In the ancient world slavery was generally seen as a voluntary institution and defended on libertarian-type grounds. Because slaves might be abused. Anyone might be abused, and the Bible seeks to address this in the case of slaves. A problem the Bible perhaps doesn’t address enough is slave labour displacing free labour and thereby damaging the society, but perhaps that wasn’t an issue in those days.