People often call this war "dumb".
IMO: this war is just the next step in the 1200-year old Shia-Sunni conflict. The Sunnis hate the Shia, and vice versa. Ever since 1979 when Khomeini came to power, the Sunnis have been on edge. The terrorist attack on Mecca shortly after made matters worse ( https://www.brookings.edu/events/terrorism-in-saudi-arabia-p... ). At first they thought they'd get Saddam to take out Iran; but that brutal war ended in a stalemate. Saudis and Kuwaitis gave billions to Saddam for this, and when it ended, they demanded refunds for a job not done.
This caused Saddam to try and take over Kuwait to wipe out his debts, which in turn freaked the Saudis out. They turned to the US to save them; which in turn pissed Osama off, who was riding tall after kicking the Soviets out of Afghanistan. Gulf War 1 happened, but that didn't placate Osama. Then USS Cole, Khobar Towers, 9/11 happened and US got dragged into the MiddleEast again, this time finally taking out Saddam.
When Trump got reelected, the Saudis and Qataris saw their chance to take out their archenemy Iran. They wined and dined him, invested billions into his and his family's shady schemes, gifted him a brand new jet. In that part of the world, every gift comes with strings attached. So, it was only a matter of time before the US would start trading blows with Iran.
And guess what? MBS is now pushing Trump to put boots on the ground: https://www.msn.com/en-us/news/world/trump-on-brink-of-groun...
The problem with the rulers of Iran was that they did not see the writing on the wall, and continued to poke at Israel via Hezbollah, Hamas, Houthies. They had already lost Syria (with the ouster of Basher Al Assad); they could have just cut their ties with Hamas and Hezbollah and made peace with Israel.