I’m not sure of the legalities, but he was offered a spot, and then it was withdrawn, and he had made arrangements to be in Las Vegas for the debates, so I think having him in the debate is the right thing to do.
It would appear that the judge made his ruling based on some sort of implied contract, and the public service requirement for broadcasters, but I’m completely unequipped to evaluate the law here, I’m an engineer, not a lawyer, dammit*!
*I love it when I get to go all Doctor McCoy!!!