Following is the best analysis I've seen:
The decision to decertify the class was 9-0, not 5-4 as widely reported. As Justice Ginsburg's partial dissent begins, "The class in this case, I agree with the Court, should not have been certified under Federal Rule of Civil Procedure 23(b)(2)." All of the justices agreed that a civil rights class action was the wrong vehicle for seeking damages that would be different for each of millions of employees. And all of the justices agreed that it would be unfair to Walmart to conduct a "Trial by Formula," calculating damages for a few employees and then giving proportionate damages to the rest. For example, female employees with female managers, who never claimed any discrimination, would have recovered damages--clearly a serious problem.
Where did the justices disagree? Justice Ginsburg would have let the employees try again to get the class certified using a different type of class action, with an even harder burden of proof. The employees would not only have to prove that they had common questions to be resolved, but that those common questions predominated over individual questions--like damages. Given the need for millions of mini-trials to calculate damages for each employee, this class too almost certainly would have failed.
Therefore, it is misguided, at best, to characterize this as a 5-4 decision. For practical purposes, the Supreme Court's opinion was unanimous.