(my response to someone posting on Facebook about this issue)
The Bible and slavery is one of those issues that comes up a lot in discussions with atheists and others who do not understand the background and context of the ancient near east (ANE). Whereas I've found that atheists are very rarely interested in two way dialog or actually open to learning anything, I'm going to take your statement that this is one of those "puzzles" for you that you really would like to understand better. So, let me suggest a book to you, "Is God a Moral Monster - Making Sense of the Old Testament God" by Paul Copan. This book is an excellent resource for clearing up this issue and many other thorny (to us) Old Testament issues.
First of all, I'm going to assume the picture of "slavery" in your mind is the horrific inhumanity of slavery of the 18/19th century. The slavery the Bible talks about is far different and was even in some cases considered an aspect of social welfare for the needy. Hebrew "slaves" had God given rights, punishment was limited, etc. Read the book. This issue is easily put to rest for those interested in understanding the facts.
It really surprises me that many Christians have never thought of it this way but the entire Bible as a whole is an anti-slavery book. If I were to write a newspaper front page headline for the Bible it would be something like this: "Master willingly sacrifices life to free rebellious slaves!" That is a foundational theme from Genesis to Revelation. Slavery to sin is far worse than 18/19th century slavery ever was. Sin can send a soul to Hell. Even the worst slave master didn't have the power to do that.
Also keep in mind the Bible talks about many things, but "talking about" is not the same as condoning. Does the Bible condon Roman occupation? Jesus was right there. He certainly could have blown them away with His breath, but He didn't.
Again, read the book. It's a great resource.