Why would EK perceive it worth the cost to fly around a certain piece of the globe rather than the cheaper direct option?
It depends on the costs; EK will fly over Iran as it doesn't cost them a huge amount to do so. But if QF were to overfly Iran then they would be guilty of breaching sanctions and so would be liable to huge fines from the Australian government and potentially shut down.
Costs for one airline are not the same as those for another.