I'd encourage you to read more objective sources about the history of modern Iran rather than ones which chalk it up to "America/CIA bad". Religious fanatics were already taking over the country in the 1920s, long before America had any interest in the region.
I'm telling this from an American perspective. The Middle East is the poster child of the harms of religious nationalism; but that's not a uniquely Iranian problem. Nor does religious nationalism or fundamentalism uniquely imperil normalizing relations with a country - Saudi Arabia has an arguably stronger movement of fundamentalists and religions nationalists, and we still allied with them.
The grandparent asked for "Why does America support Saudi Arabia when Iran is more in line with American values", and in that particular case the answer is almost entirely "CIA Bad", possibly with a dash of "right wingers use other countries' right wingers as an excuse to hate those countries".
But yes, it's entirely historical reasons. America used to actually be allied with Iran back when it was a monarchy; and this in particular is a good chunk of the reason why the two countries hate each other. The CIA in particular tried to fuck over the country and it backfired, hard. So Iran decided, instead of allying itself with the first (America) or second (USSR) world, they'd become a theocratic democracy. Once we successfully pissed off Iran; our backup solution was to ally with Saudi Arabia and Israel. Yes, the same Saudi Arabia that had just embargoed the US for being too pro-Israel a few years prior. Geopolitics is weird.
(One thing I do want to point out is that you may be measuring the gender equality of an entire country by the gender equality of it's computer programming staff. This is a mistake: those properties are inversely proportional. Iran sends more women computer programmers abroad because it's so gender unequal. In contrast, very gender-equal countries tend to produce fewer women computer programmers. Iran isn't a bastion of feminism, it's just not as bad as it's neighboring countries. In terms of gender equality, Iran is more of an Alabama than a Sweden.)