Slavery is evil, but God is able to bring good out of anything.
Whatever manner God deals with His people, whether through something He does or something He allows, it is always to bring glory to Himself. Glory is simply the revealing of God's character and nature such that we can understand and appreciate Him better. So, to find out why the Israelites were enslaved, we need to ask how God revealed His character and nature through the situation. What do we learn about God from this time?
Remember when God told Abram what would happen to His descendants, He also promised to bring great good out of it? Abraham received many promises from God, but never saw them fulfilled (Hebrews 11:13). Abraham believed God anyway, but I wonder what everyone else thought? Imagine you're one of Abram's neighbors - say, an idol worshipping Canaanite. You hear Abram say his God (of whom you know nothing) made a bunch of promises to him... but years go by and, even though Abram dies, you never see them fulfilled. Wouldn't you think his God is no different than your god? After all, your god never fulfilled any promises either.
400 years later, God appeared to Moses and said He was now going to act to fulfill the promises made to Abraham (Exodus 3:8). But the Israelites didn't know God anymore. He was the stuff of legends to them. He hadn't spoken in hundreds of years. Moses had to ask who God was so he could tell his people (Exodus 3:13-15). God then gave His name: YHWH.
Exodus 6:3 says God wasn't known by that name to Abraham, yet Genesis 12:8 says Abraham had called on the name of YHWH. I take this to mean Abraham knew the pronunciation of God's name, but it understand it has a meaning. (It's like knowing someone by the name of Cook, and not realizing he's a great chef.) God was about to show Moses and the Israelites what His name meant.
One repeated phrase in the Old Testament is "...and then they will know that I am YHWH," or something similar ( i.e. Exodus 6:7-8, 14:4, 1 Samuel 17:47, 1 Kings 20:28, etc). Every time you see this phrase, it is because God says He is going to act to fulfill a promise. So, the meaning of the name YHWH is tied with the God who acts to show Himself real and faithful to His promises.
Abraham never saw the promises fulfilled, but Moses and the Israelites did. God revealed Himself to them in spectacular ways. As a result, they came to know God better. They knew Him as Savior, Redeemer, Provider, and One who loves them. They knew He was faithful to His promises - even those made hundreds of years ago. They witnessed His power over nature and man. God was glorified in their eyes and the Egyptians', (and to the Canaanites as well: Joshua 2:9-11, Judges 9:24). The glory was greater because God had brought His people out of an otherwise impossible situation. That is the same way He works today. He comes through for us even in impossible situations.
The slavery aspect also had other benefits. It helped the Israelites to understand the relationship they had to their God. God did not set His people completely free from slavery. He redeemed them to be His own servants. He bought them: they were now His.
As Christians, we are also redeemed; we are now slaves of Christ. But we have a harder time understanding the ramifications of this because we haven't come from a slavery background. Israel knew what it meant, even though they rebelled over and over again. Thankfully, we have a Master is extremely good, and loves us.