Non-American here. From what I understand, initially, judges in the USA had the power to send people to indenture servitude for a term or occasionally for life.
Judges are supposed to be wearing the mantle of morality and conscience. It is very disturbing to see that people who are supposed to be the best example of morality, rationality and conscience, are running afoul to it. They must have had given a very rational argument for that time, for their rulings to be accepted by the legal community.
So, when judges started ruling that chattel slavery was legal, what rationale did they give in their judicial opinions?
Why would you suppose they would be any less subject to the prejudices of their era than anyone else?
The law is little more than current thinking codified prejudices included.
"Upon the whole, therefore, it is the judgment of this court, that it appears by the record before us that the plaintiff in error is not a citizen of Missouri, in the sense in which that word is used in the Constitution; and that the Circuit Court of the United States, for that reason, had no jurisdiction in the case, and could give no judgment in it. Its judgment for the defendant must, consequently, be reversed, and a mandate issued, directing the suit to be dismissed for want of jurisdiction."
This is the decision by the Supreme Court on the case of Dred Scott V. Sanford. The case surrounded a slave who was brought by his master, a military officer, to Illinois which was a free state at the time. He sued for his freedom on the grounds that slavery was illegal in the state he was residing in. Essentially what the courts decided was that Scott was property and therefore had no claim on citizenship. Essentially the judges at the time agreed that slaves did not count as citizens of the United States and of a lower status than whites. There is a myriad of social, economic, and cultural reasons why they believed this and often that came down to the individual judge making the rules.
Also recognize that judges (especially those in upper courts) are to determine how laws are to be interpreted from the Constitution. At that point in time, the Constitution and all earlier cases indicated that slaves were not in fact people. Before the 13th amendment to the United States constitution abolished slavery and the 14th amendment gave freed slaves citizenship they were not citizens, and therefore did not have the rights or protections of the Constitution. Right or wrong judges can't violate the Constitution.