Saving face. Israel has bombed Iranian targets in Syria before, but (just like Mexico and Ecuador) a strike on consular property is diplomatic taboo and any government has to follow with a "proportional response".
Seriously, if Mexico bombed the US consulate in Canada, we wouldn't let that slide. Iran is limited in proportional response options as a pariah state, so maybe launching a volley of negligible civilian threat strikes was the minimum response available. Dunno.