NVidia could protect itself against OpenAI bankrupcy by adding a clause to the lease saying that if OpenAI goes bankrupt, Nvidia gets its GPUs back. So the risk would only be that the lease would be aborted sooner than expected.
That is, in fact, the risk.
The costs are not just the raw cost of the physical asset, but also the opportunity costs of doing "thing a" vs. "thing b".
The GPUs will also depreciate during the time they're in OpenAI's possession, so again, if that investment doesn't pay off they aren't just getting GPUs back, they're getting "used GPUs" or "more used GPUs" back, not the original or full value of the originally leased asset. Naturally, the lease has to have those costs built in to be a good deal, but the lease has to fulfill to terms for that to happen.
In the end, leasing them means they carry the early risk of the lease not being fulfilled... but they should gain more in the than if they just straight up sold them.