Whilst some critical scholars would certainly argue that the Exodus never happened and wasn't intended to be read that way, that hardly represents all scholarship. There is a large body of scholarship that would argue for a historical Exodus, and there is historical evidence to support the plausibility of the events during the time they are supposed to have happened (See Tremper Longman III - How to read Exodus). But that is a separate discussion.
What Slavery Wasn't
I will answer from the perspective that the Exodus did happen and God really did establish a covenant agreement with his people. What you are seeing in Exodus 21:2-11 is not the same as the slave trade that started in the 15th century that burns in our minds. This type of slavery, referred to as chattel slavery was forbidden in Israel (Exodus 21:16).
See also Wikipedia - Jewish Views on Slavery
What Slavery Was
Slavery in this context was (at least intended) to be a social welfare system to protect ones self from their own encumbering debt or abject poverty (sometimes called indentured servitude). Perhaps you were a foreigner in Israel starting with nothing, or an Israelite with gross debt, you could protect yourself by selling yourself into servant hood for a time (See Genesis 29, Jacob serves Laban after fleeing his household).
As you can hopefully see from the passage, slavery/servant hood was supposed to protect the individual with certain rights.
The Rights of the Slaves
The fact that these rights were explicitly commanded can perhaps give you an idea of the problems slaves might have faced in other places in the world at the time:
You couldn't keep them in servitude forever, you had to release them.
Servants were not to be deliberately separated from their families upon release.
They were to have their needs provided for and not be deprived of food or clothes.
Israel were supposed to be different to to the other nations
There are some other cultural oddities in there that you would need to turn to a good commentary to explain (This site gives a comparison on various commentaries). Like many of the laws, they were designed so that women, children and slaves were supposed to have a much better time in Israel than they would have in an ancient world that could be quite violent and oppressive to these groups. Israel was supposed to stand out and be different.
But it didn't work out so great...
The problem is throughout the Pentateuch Moses explains that these laws wouldn't be enough to fix the problem of humanities hard hearts. And you see in the book of Kings and the prophets that Israel didn't do a good job living out this covenant agreement as God's people. So you see the prophets regularly condemn Israel for their oppression of the poor and slaves/servants (Amos 2:6).
Appendix 1: Foreign slaves don't seem to be included in the cycle of release, what about them?
- A convincing argument can be made that the laws in the Torah were not Israel's complete constitution. Rather they were a selection of the laws at times and places to help paint a picture of what God's people were supposed to be like (and ultimately highlights their eventual failure to keep them). See John Sailhamer - The Pentateuch as Narrative.
If this is the case, we shouldn't expect to get the full detail on the treatment of slaves/servants. But rather the law is there to paint a picture. The picture we get is that life for indentured slaves/servants (both foreign and domestic) was supposed to be better than life outside Israel.
Exodus and Deuteronomy actually make no mention of the release or otherwise of non-Israelite slaves [Wikipedia]. Leviticus 25 presents the option of Israelite's acquiring keeping foreign slaves on a permanent basis, but it is presented as an opportunity not a command.
So why might the Israelites have been permitted in Leviticus to keep foreign slaves/servants on a permanent basis? From a Biblical/historical perspective foreign slaves were likely not freed because they could not own land, and releasing them against their will would return them to poverty. Given that it was forbidden to mistreat a foreigner (Exodus 22:21) and as previously discussed the provision for servants included food, shelter and safety it is likely that this was the better outcome.