The court came to the decision it was legal because of the Separate-but-Equal Doctrine. They figured that as long as the separate facilities were equal (in that one group didn't have anything better than the other group in the same type of facility) that it satisfied the 14th amendment. Kind of weird to explain, hopefully the helps a bit.