A bitterly divided Supreme Court on Monday upheld a judicial order that could result in the release of nearly 40,000 prisoners from a California penal system so overcrowded that its conditions are, the court wrote, “incompatible with the concept of human dignity.” Justice Anthony M. Kennedy, a California native, joined the court’s four consistent liberals in agreeing that, after nearly two decades of litigation, it is time for the courts to force the state to act. “The release of prisoners in large numbers — assuming the state finds no other way to comply with the order — is a matter of undoubted, grave concern,” Kennedy wrote.