The ancient Chinese believed that after someone died, their spirit lived on in the afterworld. The spirits of family members who had died, watched over you. These spirits of your ancestors had magical powers. They could help you or hurt you. Family spirits included all of your ancestors, going back hundreds of years, any of one of whom could help or hinder.
Ancestor worship was the Chinese way of keeping their ancestors happy. They brought gifts of food and wine to their temples, to honor the spirits of their ancestors. Celebrations were held to honor their ancestors.
Shang kings, especially, believed in the power of their ancestors. The Shang wanted to ask their ancestors questions. They wanted answers to their questions. They used oracle bones (sometimes called dragon bones) to accomplish this.
First, the king would ask a question: "Will the weather be sunny tomorrow?" The priest carved the king's question on an oracle bone, which was just a turtle or other animal bone. (It was not a human bone.) Then, the priest heated a thin pin made of bronze. Once heated, the pin was held against the bone. The heat caused a series of small cracks to appear on the surface of the bone. Those cracks formed a pattern of sorts. Then a special oracle reader, usually a woman, would "read" the cracks, and provide the king with an answer to his question.
Archaeologists have found thousands and thousands of oracle bones, each with a question carved on them. The questions on these oracle bones have told archaeologists a great deal about daily life during the Shang Dynasty. The thing is, the questions did not actually say "Will it be sunny tomorrow?" What the question actually said was something like this: "If I sacrifice 8 men or 3 oxen, will it be sunny tomorrow?"
A great many people and animals were sacrificed during Shang times so that Shang kings and queens could ask their ancestors questions. The people they sacrificed might be slaves, or people who were sick or deformed, or people captured in war, or someone who upset a noble, or a noble who upset the king. No one was safe. The only thing that was important to the Shang kings and queens was getting an answer to their question.