Since the Iranian government seems to be reluctant to even admit that they are doing it, not to speak of explaining why they are doing it, we can only resort to (hopefully) reasoned speculation.
First, I don't think the "selling drones to Russia incurs the wrath of the EU/US"-argument is particularly strong here. Iran already has a heavy bunch of sanctions slapped on them anyway. In fact, I have no seen any reports of new sanctions being discussed in this context - the screws may already be as tight as they get.
Second, it is not clear to me that buying Iranian drones would be a feasible option for Ukraine. A lot of the money Ukraine uses to buy weapons comes from the US and the EU. I really don't see the US tolerating Ukraine using US subsidies to pay Iran; and the EU wouldn't be happy with that either. Of course Ukraine could try "We're not paying Iran with the money we got from you, but with this other money we got from taxes/crowd funding/etc" as an argument. But it does seem risky to potentially annoy significant supporters in this way.
Third, there may just be some "the enemy of the friend of my enemy is my friend" Cold War-style logic going on. The Iranian government hates the US, so if the US gives weapons to Ukraine, giving weapons to Russia may feel appropriate. Side benefits are getting real-life data on how well or not the drones operate against a wide range of Western air defences. (With accompanying downside: The West learns how well their stuff works against Iranian drones. We may see Gepards being put back into use or so.)
Fourth, there is more than money Russia can offer. A Russian-Iranian alliance all but eliminates the risk of the UN Security Council passing anything against Iran. Depending on just how desperate Russia is, there might even be some nuclear technology on the negotiating table.