What I think is that God understands that as reasoning beings, we evolve, and our comprehension of ethics evolves. In the time of the Torah's giving/composition (more than 3000 years ago) slavery was universal in the Ancient Near East. God was already asking us to make drastic, unprecedented, unparalleled changes in our society, like monotheism and the giving up of idols and other such paraphernalia. I think He understood that those people were simply unready for a quantum leap in ethical reconstruction. If He had demanded things that we now know to be ethical, like giving up slavery, egalitarianism between the sexes, the avoidance of warfare, and so forth, the ancient Jews would have rejected the Torah. They were unprepared to live with that level of total change. And as it was, they barely made it through with what was asked of them. God couldn't demand a complete cessation of slavery, so instead, He limited it, modified it, pushed the boundaries of what was the norm at that time, in that era, of how people could treat one another. It was radical change for that time, but not so much that the people couldn't live with it.
And more importantly, with the Written Torah, He gave us the Oral Torah, and the authority to interpret the written Torah decisively for the purposes of halakhah (Jewish Law). Which means that, as time went on, over the succeeding millennia, and our ethics evolved, so did our willingness to comprehend that something that the Torah permitted but limited might in fact be better prohibited altogether. So that, by the time of the British slavery question, most English Jews were staunch opponents of slavery; and at the time of the American Civil War, though some Jews-- shamefully-- were rich slave owners and even traders, the vast majority of American Jews were opposed to slavery, some quite outspokenly so. And we understand today that, even though the Written Torah permits slavery, that is not what God wants from us, and we know that it is right that it be prohibited to us.
As the centuries have passed, it has become ever more apparent that much of God's wisdom in giving us the Torah-- including the Oral Torah, and the power to interpret and make halakhah-- was that it was intended from the start that our understanding of what God wants from us broaden and deepen as we evolved greater comprehension of ourselves and the world around us. And so we needed to guide us a way of preserving the power of revelation, so that our Torah need not be limited to what our far ancestors could comprehend. Which is what we got.
Slavery is wrong. It was always wrong, and when we practiced it, we were wrong to do so. And I am sure that it was in part through the limitations that God had us place upon it initially that we came to eventually realize its total wrongness. That limited permission was God setting us up on the first step of a long road, which I think He knew perfectly well.