Surely the OP is titled incorrectly and it should be 'Why is it against the law for a woman to have her head uncovered in Iran?' It isn't visitors this applies to, it's all women. It then is a nonsensical question to say why don't we force visitors here to eat pork, since it isn't the law that people must eat pork.
I think there are many issues with human rights that would make me not want to trade with various nations but while I would rather that this law didn't apply , it's not one of them.