Everyone always says, “Where in the Torah does it say I can’t touch someone of the opposite sex?” Right here, folks! The operative words in our verse are not to “draw near.” As the Rambam explains, (Sefer HaMitzvos, Negative #353), “even without actual sex, such as hugging and kissing.” In other words, we may not have contact of an affectionate nature with forbidden relationships, including married women and a niddah (menstruant). Non-affectionate contact, such as a doctor or a dentist during the course of their work, is another story.
While this verse says “a man,” it actually applies equally to both men and women. As Rashi explains, the verb “draw near” is written in the plural. Since men are already included by “a man,” who else could the plural come to include? There’s nobody left but women!
The reason for this mitzvah is clear: the sex drive is among the most powerful urges in the human race. But we are not animals, we are people, so we should be able to lift ourselves above our urges. This mitzvah helps distance us from falling into a trap. If we don’t take small liberties, we won’t become complacent and ultimately overly familiar with members of the opposite sex. If we have safeguards in place, we won’t stumble in matters of a sexual nature.
This is not to say that Judaism is prudish or that sex is a “necessary evil” permitted only to perpetuate the species. Just the opposite! Sex is a good thing in its proper context, which is in a marital relationship. Just like the food we eat is elevated by the laws of kashrus and making brachos (blessings), the sexual relations of a person are elevated by the Torah from an animal act into something higher. God doesn’t say “no” to things so much as He contextualizes how they should be done to a person’s betterment rather than to his detriment.
This mitzvah applies to both men and women in all times and places. In the Talmud, it is discussed in tractate Shabbos, 13a-b, 64a-b), Kiddushin (70a-b) and elsewhere. It is codified in the Shulchan Aruch in Even Ha’Ezer 21. It is #353 of the 365 negative mitzvos in the Rambam’s Sefer HaMitzvos and #110 of the 194 negative mitzvos that can be fulfilled today as listed in the Chofetz Chaim’s Sefer HaMitzvos HaKatzar. The Ramban (Nachmanides) does not include this in his list of the 613 mitzvos. His opinion is that “drawing near” is the same as “uncovering” (i.e., the prohibition against illicit sexual relations) and that our safeguards against such relations are of rabbinic origin. (Please note that all authorities agree as to the nature of these safeguards, they only differ as to which may be Biblical and which may be rabbinic in origin.)