Russia and Iran are both suffering from maximum pressure sanctions by the US, which is attempting to crash their economies and currencies and prevent their oil and gas exports. The two cannot be sanctioned more than they already are, so defying the US to team up makes good economic sense.
We may be seeing the limits of American economic power– trying to take on both Russia and Iran at the same time, plus threatening China, may be classical imperial overstretch.
Source: Russia announces Bn. Investment in Iran Oil & Gas, as Khamenei Supports Putin’s invasion of Ukraine