In 1953 there was a coup supported by the US and UK which overthrew Iran's Prime Minister, the main driver was about Iran's sovereign rights to its own oil. Since then Iran has put millions into developing nuclear energy, so they don't have all their energy eggs in one basket. They don't want to have their right to enrich uranium taken away. There's no way Iran wants to throw away that effort. And the programme itself (in the absence of a bomb existing) is defensive for them because there's always the potential of developing one.
Iran had signed a non proliferation deal with Obama. Trump scrapped it. When people talk about Iran was given 6 months to come to talks and failed to do so resulting in the recent Iran/Israel war, they're talking about talks to get a deal to replace the one Trump scrapped. Iran has stepped up its uranium enrichment recently. Was this because they are actually working on a weapon, or was it as a point of leverage in these talks to get a better deal and economic sanctions removed?
Israel's Prime minister has said repeatedly over the last 20 years that Iran is close to making a nuclear bomb. With each repetition of this over the years, people may start to doubt the credibility of the statement. It has a bit of a whiff of the 45 minutes claim/dodgy dossier from our invasion of Iraq. Iran does have a nuclear program for engery/medical reasons but denies it is trying to make a bomb.
US national intelligence director said a few months ago that Iran was not close to developing nuclear weapons. A week ago CNN and the Wall Street Journal amongst others said they'd been briefed by US government that Iran was not currently persuing development of a bomb, and they were 3 years away from being able to deliver a nuclear bomb to any specific target. (enriched uranium is not the same thing as a useable bomb)
So it didn't look like this was an immediate threat which required a milatry intervention. There was likely time for more diplomacy. Recent attacks on Iran are likely to push them towards developing a bomb at greater speed to defend their population/country. Because they're now under actual attack, they're motivated in a way they weren't previously. Israel's strikes targeted nuclear scientists and military. They destroyed the physical infrastructure where they could. But they lack the big bombs that the US has which can destroy underground infrastructure. Israel PM likely told Trump he had to help now because the job Israel started a week ago needed to be finished, or else Iran's top priority would now be developing the bomb. Was Trump backed into an obvious corner here? Did he have another option? Has he actually completly removed Iran's ability to develop a bomb? Anything less would be dangerous as outlined above. And aside from that danger, what other conventional weapons might Iran use in response and against who? Will those be direct attacks against military targets in the region or the public? Or will they be terror style attacks? And the obvious point, that people have died and suffered and more will the longer this escalates and continues.