It's naive to call them an ally. It's an extremely complicated relationship, made more toxic by the extreme power that AIPAC holds over our politicians. Every president since LBJ has been duped, outwitted and embarrassed by Israel. Frenemy would be more accurate.
Another reason is that Israel is a relatively stable, Western aligned democracy in a sea of dictatorships, kingdoms, fiefdoms and failed states... which are all organized in OPEC. The US needs a powerful Israel as a check-and-balance against OPEC - a credible threat that if OPEC ever repeats another Oil Crisis, they'll get putsched away.
> They routinely spy on the US, and according the the CIA, spy on us as aggressively as the Chinese and Russians do.
So what, I'm German, y'all spied on Schröder and Merkel as well, and it's only thanks to Snowden we actually know of that.
Well, and that power can be abused as well, particularly for a military that relies on fossil fuels as extensively as the US. Additionally, there's not just the "classic" way of fighting wars (i.e. shooting stuff and blowing up stuff), but there's also economic warfare - and hiking the price of a vital good in war is an extremely effective weapon.
And it's absolutely true that they did not sign the nuclear non proliferation treaty, and then went on to do nuclear tests off the coast of South Africa in the 1979 Vela incident. And that provided a huge motivation for Israel's enemies (which are absolutely anti-US) to seek nuclear weapons, which caused huge regional instability since then and threatened US national security.
Yes, you can talk about how it's hypocritical that the US gets to do these things and nobody else does. And in a sense it is, but the fact is that at the moment, the US effectively rules the world for better or worse. And it is a fact that Israel's behavior is causing instability that threatens themselves and the US.