When Dred Scott, a slave, was taken to the free Wisconsin territory, he tried to buy his freedom. When that failed, he sued that he should be set free because the Missouri Compromise dictated that slavery was banned in free states and territories. How, he argued, could he be a slave in a territory that forbade slavery?
The Supreme Court decided, however, that the Missouri Compromise was wrong. In part, they based their decision on the following clause in the Fifth Amendment to the US Constitution that said a person could not "be deprived of life, liberty, or property, without due process of law."
Since a slave, at least in the slave states, was considered property, the property couldn't simply be set free because it crossed state lines. That would be like saying you no longer owned your sofa because you had crossed into a state that banned sofa ownership. What belongs to you in one state belongs to you in any other state or territory, the court decided.
The fundamental moral problem, of course, is in the designation of any human being as another person's property. The Dred Scott decision led to a high degree of outrage, was seen as intending to perpetuate and spread slavery, and contributed to the start of the Civil War. The problem was ultimately settled in 1865 by the Thirteenth Amendment, which abolished slavery.