Can someone explain how he ever hoped to win this?One could say it's because the guy's basically a nutjob of sorts. But that's be oversimplifying (if ever so slightly).
The more nuanced explanation is that -- like a lot of rich techies -- he apparently subscribes to an intellectual culture that believes that now matter what written laws say -- states and other governmental entities actually have limited legitimacy, and in effect are fundamentally subordinate to "common" or "natural" law. Specifically when it comes to the "rights" of owners of real property.
So just because the law says something -- something silly about a requirement to grant the unwashed public "access" to a plot of land that, after all, you bought and paid for -- as the land owner, you really don't need to pay any attention to it. Or if you want to be a big craftier, you can just say "I don't like this current jurisdiction's laws, and I'd prefer to respect the laws of its (for some 150+ years) vanquished predecessor instead."
So if people come after you in the courts -- hey, if you can afford lawyers sufficiently skilled so as to bamboozle either the justices in the jury with lofty-sounding talk about how, actually, the chain-of-title goes all the way back the land grants made by the Mexican Empire (and hence, you only have to worry about what its laws say about any requirements for public beach access) -- then more power to you.
Which is actually the route Khosla took in this case.