If a man rapes a betrothed maiden, it’s an act of adultery. Nevertheless, only the man is punished; the girl in this scenario is blameless because she was compelled. This law is not limited to this situation; in general a person who commits a crime under duress is exempt from punishment.
The reason for this mitzvah is obvious: it’s not fair to punish someone for something they were forced to do against their will.
This mitzvah applies even in the case of two of the three mitzvos that one should perish rather than violate. That is, one should give up his own life before committing murder or idolatry but if he didn’t, he is not held liable for his crime. However, if a man commits an act of adultery or incest under duress, he is liable because, unlike a woman, a man is unable to perform sexually without a certain degree of interest.
Ramban (Nachmanides) does not count this as one of the 613 mitzvos. Rather than a command (“do not punish her because she did nothing”), he considers it a statement of fact (“she is not punished because she did nothing”).
This mitzvah applies in all times and places. It is discussed in the Talmud in tractate Baba Kama (28a-29b – see in particular 29a) and in Avodah Zarah (54a). It is codified in the Mishneh Torah in the twentieth chapter of Hilchos Sanhedrin. This mitzvah is #294 of the 365 negative mitzvos in the Rambam’s Sefer HaMitzvos; it is not listed in the Sefer HaMitzvos HaKatzar of the Chofetz Chaim.