The Jewish people have been freed from slavery. They received the Ten Commandments at Mount Sinai. Shortly afterwards, at the beginning of this week's Torah portion, G-d begins by laying out a series of enactments. The first set of enactments have to do with owning slaves (Exodus 21:2-11). Hold on a second! Didn't G-d just free us from the awful institution of slavery? All that showboating and G-d still allows slavery to take place? What gives?
If we take a closer look at the passage, the institution put into place is much closer to indentured servitude than it is slavery. The period of servitude is only six years, and during the seventh year, he shall go free (Exodus 21:2). Even when dealing with additional parties, such as a wife and child (ibid, 21:3-4, 11), there are still ways for all to be emancipated.
But let's forget the semantics between "slavery" and "indentured servitude" for a second. Why allow for any period of time in which an individual works for another without just compensation? It seems so counterintuitive for G-d to punish the Egyptians for inflicting slavery on the Jewish people, only to allow for fellow Jews to become slaves in some form or the other.
Allow for me to provide an interpretation that will not completely offend our modern-day notion of morality. It is human nature for people to want to maintain within their comfort zone. Change is scary. Even when people do decide to change, the vast majority of human beings need to do so in a gradual manner. Maimonides pointed this out with regards to leading the Jewish people out of Egypt (Guide for the Perplexed, III, xxiv). According to Maimonides, G-d led the Jewish people away from the direct path (Exodus 13:17) because He did not want the Jewish people to become discouraged and want to return to the comfort zone of slavery. G-d helped in such a way without taking away that which makes us human.
Humans need time to adapt to change, and G-d was well aware of that when enacting these laws. If you need another example of G-d's understanding in this matter, look at the Jewish mourning process (שבעה). The typical human cannot cope with the loss of a loved one instantaneously. G-d gives us time to mourn. Even so, G-d puts a limit on the time it takes to adapt, which is why the maximum time for mourning is eleven months (which is the longest mourning time [reserved for one's parents]).
Much like with שבעה, G-d gave the Jewish people a certain period of time to adapt to being freemen: six years. If, after the seventh year, the slave decides to remain a slave, the master takes the bondman to the doorpost and pierces his ear with an awl (Exodus 21:6). Why? Because at that point, the bondman has declared himself to be property. The reason why the series of laws begins with those regarding indentured servitude is because freedom is a prerequisite for following laws. Without free will, laws, morals, and ethics are pointless. By removing ourselves from our own modern-day slaveries, we can truly appreciate what it means to be human.