JERUSALEM—The Oct. 7, 2023, attack on Israel was the greatest security failure of Benjamin Netanyahu’s career. Less than three years later, the Israeli prime minister is pursuing what may become his defining strategic achievement: toppling the Islamic Republic of Iran.