Ok....someone....anyone....remind me how a court....can re-write any law? Or in other words re-write the context of the lawsuit. The lawsuit against the obamacare (aka ACA) was based on the Individual Mandate, also the ACA references Individual Mandate, not tax. Personally from a logical, legal and common sense approach, the ruling is null and void.
There is ample precedent that the Court should not rewrite the laws, yet the Roberts Court did so. The only guard against that is to have the Senate do its job when giving its "advice and consent" to presidential appointees; even that does not always work because justices change their views over time and due to desires to do what is "right." They rarely should but they do.
No President is prescient about what a Supreme Court appointee may do years after he is confirmed, and neither is the Senate. I don't know of any solution beyond electing Presidents and CongressCritters who will do their best, imperfect though it may be, to avoid that sort of thing. And that's up to us.