In this chapter, God establishes a variety of laws governing slavery and restitution for personal injury.
This is the second chapter in a row where literally the entire chapter is nothing but the LORD speaking (probably to Moses, who later recounts these things to the people). I hope you're getting used to lengthy dialogue because we still have a lot left.
The ordinances regarding slavery are one of the things I had in mind when I gave my prior rant about progressive revelation. People sometimes interpret this passage as, "not a negative makes a positive." That is, because it does not prohibit slavery, God is actually OK with slavery. There are three reasons why this logic is not correct. The first is that all of the rules here are limitations on slavery, constraining male slavery to 6 years and several different protections for female slaves that would not otherwise exist. The second is that these rules are progressively revealed: from the beginning of the bible up through this point, slavery existed without any governing rules from the LORD. That means these rules exist as a form of progressive revelation. However, the most important part is to keep in mind what the LORD is revealing. The revelation here is not about the nature or acceptability of slavery, it is about creating a governing structure and covenantal treatise between the new Hebrew nation and the LORD. To read it otherwise is contrary to the purpose of the text.
The last point is that the revelation here is itself superseded by by further progressive revelation from the NT. Contrary to popular criticism, this is not a "bloodthirsty OT god" and "cheerful NT god" thing, it's the same God but revealing different attributes to suit the time and place of the revelation. Remember that the OT is the very first picture that we have of the LORD. All of the things that people take for granted when discussing God, such as omnipotence, omniscience, etc, are concepts that were first established by the OT itself, and we have seen many of these aspects already. One cannot criticize the OT for not covering these much more specific topics (like slavery) while presuming so many more basic topics that the OT is, in fact, trying to demonstrate (like the omnipotence of the LORD). One might as well criticize a calculus textbook for not also including differential equations; yet the critic would not understand differential equations without a priori knowing calculus. The same principle applies here: when reading the OT, try to learn what the OT is trying to teach, because so many things we take for granted now were controversial when first written.
With all that in mind, we can obviously imply from this passage that slavery would indeed be an institution in ancient Israel. This passage only deals with Hebrew slaves, who would sell themselves (or by sold by their parents) in exchange to pay off a debt of some kind. This slavery is term-limited for males, so that's closer to indentured servitude. For women, the expectation is that their new owner would appropriate them as a concubine or wife, which is why their slavery is not term-limited, but rather most of their protections are to keep them from abuse by their new husband. Foreign slaves would either be bought or acquired through military victory and would not have the same level of protection as native Hebrews.
The laws regarding personal injury are strikingly similar to our own. We can see that they had multiple classes of murder depending on the intent and premeditation of the murderer that are treated accordingly. When it says "I will appoint you a place to which he may flee", this is foreshadowing certain "cities of refuge" which are later opened up that unintentional murderers can flee to and be immunized from retributive punishment (i.e. execution). When verse 14 says "you are to take him even from my altar", the reader should understand that clinging to an altar is a Hebrew concept that basically equates to begging for mercy. While the altar is currently just a symbol of worship or homage, it will later become a symbol of atonement or mercy, for those seeking divine favor. This verse foreshadows that later symbolism.
Similarly with the "ox goring a man" part; if the ox is "in the habit of goring and its owner had been warned", then to not restrain the animal is negligence and earns a death penalty.
The part that's different is their obvious acceptance of the death penalty for many crimes that only lead to imprisonment in the US today. Not a single crime here results in imprisonment, so one can wonder if they even had prisons. We also see laws prohibiting "striking" or "cursing" ones parents, both on pain of death. The laws regarding injured slaves is obviously specific to slavery and is not found in most modern laws.
Verse 22 has been debated because it is one of the only references to whether the bible treats an unborn infant as alive for the purpose of legal protection (cf. abortion). I think there are other places that can better inform our views on abortion, but this is one of the most direct. Most of the commentaries I've read believe that "yet there is no injury" includes injury to the prematurely born child as well as the woman. I've heard some people say that "premature birth" specifically indicates that the child also dies, i.e. stillborn. I don't believe that's correct, although on this point it greatly depends on the specific interpretation of the Hebrew for this passage so I won't push this point too much. Possibly if miscarriage (i.e. abortion) were inferred, the author would have used "shakol", to miscarry, abort, destroy or cast off [one's young], like we see in Ex 23:26, instead of "yatsaw", to go forth or depart. Verse 23-25 indicates that any further injury to the without specifying the injured party (could possibly include both woman and child) would be met with equal force.
From a sociological perspective, we can discern a number of things about Israelite society from this chapter. I already mentioned they used slavery, widely accepted and used the death penalty and legally protect parents' authority over their children. We can also see their free use of animals and the sometimes dangerous nature of these animals, that an ox could have a reputation for goring. And people would just dig pits? I wonder what they would use these pits for, that they would dig a pit and leave it uncovered such that animals accidentally fall down them and die.
Now we're starting to see legal enforcement of the ten commandments, as there are now laws (with applicable punishment) against murder and disrespecting one's parents.