Especially with Iran becoming a theocracy.
It’s important to note that while Iran became a theocracy after the revolution, this was, from a realpolitik perspective, good for the Soviets. The Soviet Government had long antagonized the Shah’s regime that came before the revolution, sponsoring rebellions in the north of Iran during the 40s. The Shah’s regime was markedly more pro-western then pro-Soviet, with western powers such as the British and Americans supporting him in asserting control over the populist Prime Minister Mossadegh in the infamous 1953 Mordad coup, whose base included the fervently pro-Soviet “Tudeh” Party, although the Soviets chose to avoid supporting Mossadegh directly.
This intensified throughout the 1960s, with the Shah moving closer and closer in relations to the Americans and seeking out an alliance. It was thus, while the revolution may have seemed bad to the ideals of socialism, it was generally a good thing from the perspective of a Soviet Party Politician. So, to curb American influence, Soviet party propaganda supported the revolution, painting the new regime as a great bulwark against American feudal imperialism. Iranian communists, such as the Tudeh Party, went along with this, as much of their party line had involved following the example of the Soviets. Even into the Islamic regime, in its early years, the Soviets still painted it as a good thing.
It’s important to note that the revolution itself did not revolve around Islam solely. Those rising up against the Shah were multi-faceted with different motivations, with the Shah’s connections to the west being one for many. Communists, moderates, republicans, landowners, Islamists of all kinds, and others rose up in opposition to the Shah’s various policies, clamping down on dissent, and fervent westernization, which antagonized many. This of course also meant many factions in the revolution were not fond of the Soviets. The chant Marg Bar Shuravi, translating to “Death to the Soviets” was popular even in the early days of the revolution alongside other chants condemning nations such as the United States, Israel, and Britain with death.
This example of Revolutionary Iran’s antagonism towards the Soviets continued into the early 1980s, the death of Soviet Support of the revolutionaries. After the new theocratic government under Ayatollah Ruhollah Khomeini consolidated control, they embarked on a purge of leftist parties, including the Tudeh, beating and killing their leaders, and torturing figureheads until they professed loyalty to Islam, upon which they would be broadcast to the nation as an example. This drove the Soviets away from the Islamic Regime, as many Iranian leftist groups, which had been forced into exile from the purges, were Soviet-supporting. In the Soviet politburo it was said that Islamic Governance and its implications wasn’t too understood, and the purge has been theorized to have been a stern reminder that the new government was not pro-Soviet and not socialist in the least.
As a final addendum out of the scope of the question but related to Soviet-Iranian relations, it is said that in the later 80s, Ayatollah Khomeini wrote a letter to General Secretary Gorbachev of the Soviet Union, stating that communism was past its prime and urging him to shift the Soviet Union to islam. It didn’t work, although the Iranian government has used this letter to claim that Khomeini predicted the union’s collapse.