Iran + Western nations / US / its close allies = recipe for detention, accusation of being a spy, and a longer stay in that country with a fair bit less hospitality than you may have planned. Period, end of story. If you're American, just avoid Iran, North Korea, and Venezuela right now. I'd throw Syria, Iraq, and Afghanistan on that list for the better part of a generation, but some parts of Afghanistan (Wakhan Corridor) are and have been relatively trouble-free even during the worst of the fighting since 2001 - you just have to get there.
The US State Department maintains an email blast you can sign up for via their website (
https://travel.state.gov/content/travel/en/international-travel.html) that includes travel warnings for US citizens and they will provide you with more detailed information on particular trouble spots if you ask them; and generally if you desire to travel in a given country and that country maintains a consulate or embassy in the US, you can reach out to them to get advice also - and may have to for travel visas anyway.
As others have said, study the culture, do your research, make a plan, have contingencies in place, and be open to the new and unexpected experiences. In most places of the world, if you make even a token effort at reaching out to locals with a little bit of broken native tongues and with humility and respect for them, you will be rewarded with hospitality beyond your expectations.