It wasn't legitimate from the outset, but the Roberts Court contorted itself to make it "legal" because they didn't want to get accused of racism in killing Obama's signature legislation.
Fast forward and it's not fostered single payor, and it has led to healthcare inflation, so much so that the government has to provide subsidies so that people can afford it. Complete failure.