I believe the court ruled that it was a tax, which congress is empowered to levy, not under the general welfare clause, which if I am not mistaken was a clause designed to encompass national security, safety, freedom, and unrestricted commerce between states.