Tehran Bureau has an enlightening piece on the politics of the coup:
Why The Election Was Stolen
[One goal of the coup] is to start preparations for the eventual successor to Ayatollah Khamenei. He is known to be ill. By accusing Mr. Rafsanjani of corruption, the second-generation revolutionaries wish to eliminate him the head of the Assembly of Experts appoints the Supreme Leader as the natural successor of Ayatollah Khamenei, hence paving the way for Ayatollah Mesbah Yazdi who is a member of the [Assembly of Experts]. Everything appeared to have been planned well in advance, but the coup leaders did not expect the people to stand up to them.
This is a pivotal moment in Iran’s history. If the reformists and the Iranian people cannot reverse the outcome of Iran’s rigged elections, Iran will enter a dark period of dictatorship, with no light at the end of the tunnel. The country will be controlled completely by the military/security forces, with an unelected Supreme Leader as its titular head, and no elections (or extremely meaningless ones). This would be a terrible development for the rest of the world as well.