Since God regulated slavery in the Old Testament, does this automatically mean that He approves of slavery? Just as some answer "yes" today, the Pharisees also jumped to a similarly wrong conclusion in Matthew 19 when they asked Jesus a question:
"Is it lawful for a man to divorce his wife for any reason at all?" And [Jesus] answered and said, "Have you not read that He who created them from the beginning made them male and female, and said, 'For this reason a man shall leave his father and mother and be joined to his wife, and the two shall become one flesh'?...What therefore God has joined together, let no man separate."
They said to Him, "Why then did Moses command to give her a certificate of divorce and send her away?" He said to them, "Because of your hardness of heart Moses permitted you to divorce your wives; but from the beginning it has not been this way."
Notice what happens here. The Pharisees come with a legal question about which regulations ought to govern divorce, and Jesus responds in a very unexpected way, saying there shouldn't be any divorce. The Pharisees are immediately confused. "But how could it be that there shouldn't be any divorce if God regulated it? Doesn't that mean He thinks it's hunky-dory as long as it's done right?"
Jesus makes it clear that this is not the case.
The Pharisees had missed something very important about law: there's a difference between what's legal and what's moral—between the practical need to deal with reality and the existence of an ideal. The Law was not meant to be an exhaustive list of everything moral and immoral. It functioned as every national set of laws functions—as reasonably enforceable rules to govern their society. And the Pharisees had made the mistake of focusing on merely staying within the regulations instead of going beyond them to seek the goodness of God's ideal.
As with divorce, the same was true for slavery. The rules regulating slavery were added "because the hardness of the hearts" of humanity had created a situation where slavery existed and served certain functions in their societies, "but it was not that way from the beginning." In the beginning, there was human dignity and equal value resulting from the fact that every single individual—young or old, rich or poor, royal or commoner—was made in the image of God. But after the Fall, the ideal society was out the window, and God had to deal with what was actually there.
Deeply ingrained cultural patterns don't change overnight, but must be redeemed over time. Slavery was intricately woven into the cultures of the day, so, as with divorce (neither being the situation God desired), God made rules to keep the evil of the practice to a minimum. For example, if you kidnapped someone and made him a slave, you were put to death. If a slave escaped from his master for whatever reason, you were not allowed to return him. If you harmed so much as a tooth of your slave, you had to let him go free—in other words, no person was allowed to keep a slave if he mistreated him or her. Slavery in Western countries would never even have gotten off the ground had these rules been followed; the first rule alone would have prevented it.
Regulating a bad situation is not a foreign concept to us. We see some people using this same principle today regarding abortion. They say it's too much a part of our society at the moment to enforce a complete ban, though abortion is immoral, so they support regulating certain things about it for now in order to reduce the evil of it (banning only partial-birth abortions, or third trimester abortions, or regulating the issues surrounding abortion, for example). That doesn't mean either that they think abortion is fine or that they intend for the situation to remain in that same state forever.
God regulated divorce, and yet He explicitly said He hates it, so the regulation of the practice did not mean He condoned it. Therefore, one cannot assume that God's regulation of slavery meant God condoned slavery.
All that said (and much more could be said), the question remains: If God opposed slavery and would need to redeem the culture from it slowly over a long period of time, why not just prevent it from ever existing in the first place? The same question could be asked of all suffering that results from human sin—why does God allow it? Since the Fall, suffering has served an important purpose in this world. God's highest goal for us is not our comfort, but our more intimate knowledge of, appreciation of, and love for Him. The existence of suffering around us has long been used by God to remind us of the ugliness of sin—a physical illustration of the fact that our hearts are far from God's perfection, and a reminder of our desperate need for Him and His mercy.
Slavery has served this same purpose. Freedom is God's ideal—the kind of freedom found in the Garden at the beginning before the Fall (that is, the freedom to follow God openly and completely, without hindrance). And God's rescuing the Israelites from slavery served for them (and for all generations) as a physical illustration of a spiritual truth. Because they understood the meaning of physical slavery, the invisible truth of their spiritual slavery to sin and their need for redemption could be made visible for all to see and understand. And because they knew God orchestrated their release from slavery, they knew not only that slavery—physical or spiritual—was not the ideal, but that He cared about their condition and desired to release them from it.
The existence of slavery in the world taught God's people both the condition of their own hearts and a crucial truth about their great, good God. This is why it was Christians in the 18th and 19th century who not only worked to see that others were freed from their spiritual slavery, but who also led the way in following God's desire to free others from physical slavery.
As with the other suffering of history, God did not prevent slavery from ever existing, though He could have. But this was neither random, senseless, nor in vain. Just as Joseph said of his own suffering as a slave that "[they] meant it for evil, but God meant it for good," slavery did not pass through this world without accomplishing a purpose even greater than the suffering.