Obama and Biden pursued a policy of appeasement towards Iran. They even went so far as providing Iran with cash and not enforcing sanctions against Iran. The nuclear agreement reached by Obama was a joke, it guaranteed that Iran would be able to construct a nuclear device and allowed Iran to continue developing ballistic missiles. (Those demonstrated policies of appeasement may have led Iran to believe that the US was nothing more than a blustering (to borrow a term from Mao Zedong) paper tiger. So they could do what they wanted with impunity.)
Consider this, the rulers of Iran have been hysterically screaming "Death to Israel and death to the US" for approximately 50 years. Iran has been supporting terrorists such as Hamas, Hezbollah, and the Houthis. At a certain point, you have to take action. Sure diplomacy should be the first step, but Iran has not been serious towards achieving a diplomatic solution. Given Iran's refusal to negotiate, time was up.