An important point. The Constitution is quite specific on what kinds of taxes Congress is allowed to impose:
Article I, Section 2 Clause 3: Representatives and direct Taxes shall be apportioned among the several States which may be included within this Union, according to their respective Numbers,This tax is none of the above.Article I, Section. 8. Clause 1: The Congress shall have Power To lay and collect Taxes, Duties, Imposts and Excises, to pay the Debts and provide for the common Defence and general Welfare of the United States; but all Duties, Imposts and Excises shall be uniform throughout the United States;
Amendment XVI (Income tax amendment)
They COULD have made it legal, by raising taxes in the amount of the "penalty", and then giving back the same amount as a credit to those who had purchased qualified health insurance. But they didn't structure it that way.
However, Roberts suggests but does not flatly write that the tax is an "Income Tax." I believe he deliberately does not attempt to justify that conclusion because the Nonsense Coefficient of his ruling is already near criticality.