It’s a debt that is owed by the UK to Tehran dating back to the 1970s.
It would not be a ransom (the UK doesn’t pay ransoms, ever, apparently).
Iran paid the UK £400M (well, the 1970s equiv) for tanks. Then came the Iranian revolution. The UK never provided the tanks as they would no longer provide weapons to such a regime, and of course still has the £400M.
The UK has been unable to give the £400M back to Iran, as there are sanctions in place against Iran.
The powers that be are presumably trying to get the £400M back to Iran in a way that would not breach the sanctions, perhaps by giving it via aid to Iran.
So I think it would be a good use of money as it’s money owed and would be a means to an end to get Nazanin (and others who are held captive but their cases have not been publicised) home.