We look at gerrymandering through the lens of "fairness", and we find it unfair when one group cannot get reasonably proportional representation in the legislature. But we are all members of many groups. We belong to political parties, racial groups, regional groups, economic groups, social classes and personality groups -- how can all of them get a voice which is proportional to their numbers? There's no clear-cut solution.
This is the core problem with most gerrymandering jurisprudence -- it looks at at the problem mostly through a racial lens, and more recently, a partisan one. But the world is more complex than that. Voter's interests are not solely determined by the color of their skin or their political party.
The court is not saying that gerrymandering is okay. The court is saying that they don't have a solution, or at least not one that can be imposed by courts. The court is more constrained than a legislature in finding a solution, because the court must override state laws based on a reasonable reading of federal law, in this case the Voting Rights Act, or the Constitution. And unfortunately, both of those sources are nearly silent on the matter. It is not within the courts power to create law from nothing, notwithstanding Kagan's dissent.
In the past, we decided that the appropriate grouping for the election of representatives was geographic. It's not ideal, but it's the best of bad options. Our current gerrymanders are a perversion of that principle, and we are right to look for a solution that leads to cleaner, more compact districts.
The court has said that it's not theirs to decide the issue. I'm not sure I agree, because current gerrymanders are an incumbent protection racket, and that looks to me like a civil rights violation. But in any case, it is well within the power of Congress to fix the problem through an amendment to the Voting Rights Act, and they certainly should.