The Supreme Court’s reversal of precedents many Americans viewed as settled rights was decades in the making.