(Side note: That... seems like a very high figure to me?) For comparison the US spent close to $1 trillion in 2024 on the military. It could have saved lives and spent that money on healthcare. But that's not how govts work. Iran didn't get a drawstring bag with 2T in it and chose to throw it all on nukes.
Additionally, you're trying to bring a (totally valid tbf) logical argument ("Desalination is critical and an excellent place to spend money that's not going into saving lives") to a government that behaves like a cornered wild animal. It will act to save itself first, even if attacking the aggressor hurts itself too in the process.