The elections occurred after the Hafte Tir bombing, which killed Mohammad Beheshti and dozens of other Iranian officials on 28 June 1981.
[1] Rajai was killed a few weeks later on 30 August 1981, together with his prime minister, Mohammad Javad Bahonar.
The reason for the July election was due to the impeachment of the President of Iran, Abolhassan Bani-Sadr (r. 5 February 1980 – 20 June 1981).
Bani-Sadr was impeached due to allegations stating he was attempting to undermine clerical power in Iran.
Ayatollah Khomeini was at the top of these allegations since he was the Supreme Leader and a marja' (someone of high clerical ranking in Shi'i Islam) in Iran.
After Bani-Sadr was found in hiding, he and his followers fled to France or were exiled (this information varies by source).
[7] As for the Islamic Republican Party itself, it was founded in 1979 by Iranians of high clerical status and approved by Khomeini.
Mohammad-Ali Raja’i was (the first) Prime Minister of Iran prior to the impeachment of Bani-Sadr, then he was part of the committee that fulfilled the presidency until the election.