The problem is that the airline isn't sure that your home country will let you enter. And if your home country doesn't let you enter, then the airline has to take you back immediately and that's a major pain for them. Imagine the plane is supposed to go from the USA to Iran to India, then they might have to take you to India and then get you to the USA somehow.
So whether you are legally allowed to enter Iran or not, if you can't convince the airline of that, then you'll have to stay in the USA. And the airline wouldn't want to take the risk. Even if you are able to buy a ticket, that doesn't mean you will be allowed on the flight once you come to the boarding gate and your passport is checked.
If you have to go through another country, that makes it just worse, because at the US checkin they can't know that the second country allows you on the flight to Iran. Plus there's the risk that you might not be allowed on a return flight with an expired passport.