For the record, in the recent past (and relevantly, after the 2022 Russian invasion) Iran did make some formal moves to make itself less unaligned, invalidating one of the fairly voted answers here:
DUBAI, Sept 15 [2022] (Reuters) - Iran has moved a step closer towards
becoming a permanent member of a central Asian security body dominated
by Russia and China, as Tehran seeks to overcome economic isolation
imposed by U.S. sanctions.
Foreign minister Hossein Amirabdollahian on
Thursday said Iran had signed a memorandum of obligations to join the
Shanghai Cooperation Organisation, which is holding a summit this week
in Uzbekistan.
The body, formed in the 2001 as a talking shop for Russia, China and ex-Soviet states in Central Asia, expanded four years ago to include India and Pakistan, with a view to playing a bigger role as counterweight to Western influence in the region.
"By signing the document for full membership of the SCO, now Iran has entered a new stage of various economic, commercial, transit and energy cooperation," Hossein Amirabdollahian wrote on his Instagram page.
And actually
On July 4 [2023], Iran officially became a full member of the Shanghai
Cooperation Organization (SCO) during a virtual summit hosted by India
for the SCO Heads of State Council (Shargh Daily, July 4). Iran
initially joined as an “observer member without voting rights” at the
July 2005 summit in Astana and, after 16 years, was accepted as the
ninth member of the SCO at the September 2021 summit in Dushanbe,
Tajikistan (Al Jazeera, September 17, 2021). Since then, Iran has
received parliamentary approval for membership documents and protocols
from the Islamic Consultative Assembly and submitted the necessary
documents to the Secretariat of the SCO.
Iran’s membership in the SCO marks the country’s first foray into a
regional organization with a defense and security function since its
withdrawal from the Central Treaty Organization (CENTO) in 1979. This
development with have a number of consequences in different areas—one
of the most significant being its impact on the security arrangements
in Central Asia.
(N.B. interesting, albeit somewhat dated 2016 reading on the SCO military exercises: these evolved from an antiterrorism focus to full-blown combined arms drills. And their frequency increased over time.)
Some Russian lawmakers have extended an invitation for Iran to apply to CSTO as recently as 2024. Such invitations seem to go back as far as 2007, even.
We know less about Iran's reluctance to these overtures, alas. Perhaps Iran sees SCO as different enough in nature from the CSTO to apply to the former but not the latter. We know that Iranian observers regularly take part in the CSTO Parliamentary Assembly, so they are not totally allergic to it, at least on that political level.
One has to keep in mind that help from Russia to Iran has been pretty slow though, especially since the war in Ukraine turned to a full-scale invasion. The vaunted Su-30s or -35s have yet to show up in Iran, despite years of talks and apparently signed contracts.
And on that level, 'news' of Chinese military cargo planes delivering aid to Iran since June 13, appear to be fake or at least unconfirmed on slightly deeper analysis. Although Iran did purchase a lot of missile fuel from China earlier.
It may be that Iran thought that their recent bilateral treaty with Russia was good enough, or least as good they could get. An Iran-aligned source commented in April:
Yet even if it does not constitute a military alliance, the treaty details mutually agreed moves if there is an attack or threats to either nation’s national security – as in Trump’s careless bombing threats against Iran. The treaty also defines the vast scope of military-technical and defense cooperation, including, crucially, regular intel talk.
But does note some divergence on foreign policy, for instance
The official Moscow position on the Axis of Resistance is an extremely delicate affair. For instance, let’s look at Yemen. Moscow does not officially recognize the Yemeni resistance government embodied by Ansarallah and with its HQ in the capital Sanaa; rather, it recognizes, just like Washington, a puppet government in Aden, which is in fact housed in a five-star hotel in Riyadh, sponsored by Saudi Arabia.
The same applies to Lebanon's Hezbollah, which was a key Russian ally in routing ISIS and other Islamist extremist groups during the Syrian war. When it comes to Syria, the only thing that really matters for official Moscow, after the Al-Qaeda-linked extremists took power in Damascus last December, is to preserve the Russian bases in Tartous and Hmeimim.
Relatedly, other observers have noted too that Russia tries to balance their relationship with Iran with their relationship with Arab countries, siding with the UAE rather than Iran in some island dispute. So despite some (Russian) parliamentary invitations to the CSTO, i.e. from the "peanut gallery", who knows if Putin would really approve it.
Contra to the rosy view in some pro-Tehran venues, other observers read the opposite in that recent bilateral treaty namely that
it turned out to be little more than a bureaucratic summary of the current state of affairs, with dozens of abstract phrases such as “confirm commitment to,” “aspire to,” and “facilitate.” [...] It also shows that the Kremlin remains unwilling to come to Iran’s aid if it is attacked by either the United States or Israel.
And conversely,
Iran—unlike North Korea—is not prepared to send soldiers to fight in Ukraine and plug the Kremlin’s manpower shortage.