Iran has shifted its terrorism efforts from Iraq (where efforts failed) and Afghanistan (where backing the anti-Shia Taliban was unpopular in Iran) to Israel and Egypt. Why Egypt? Because it, along with Saudi Arabia, is one of the major Sunni Arab countries opposing Iran, Iranian nuclear weapons programs, and Iranian plans to become the leader of the Islamic world, and spread the minority (about 10 percent) Shia form of Islam, at the expense of the majority (over 80 percent) Sunni form.
Iran isn't as vocal about this as it would like to be, because they also believe all Moslems should be united in their opposition to Israel even existing, and the Christian West in general. This view is not shared by many of Moslems, and Iran knows it. But being true believers, the militants who control Iranian diplomacy and special operations, consider terrorist attacks against Israel (a hard target) and Egypt (a much easier target) a suitable consolation prize.
You have to at least admire Iran's dogged determination to kill anybody they perceive as enemies even after getting thumped in Iraq. But why not? As long as we always play defense, why shouldn't Iran keep trying? They just have to succeed somewhere and they make progress, even if they fail in five other spots. And now Egypt is in focus.
Iran makes it clear that we are their enemy, too. Why do we refuse to listen to them?
Why do we keep playing defense?