“You shall be holy, for holy, am I, Hashem your G-d” (Vayikra 19:2). What is “holiness”? Rashi, based on Vayikra Rabbah (24:4 and 6), explains that being “holy” means “being removed (separated) from illicitness and sin, for wherever you find protection [built to prevent] illicitness [discussed] you [also] find holiness [mentioned].” Rashi and the Midrash then proceed to list examples of verses that both describe avoiding illicitness and mention holiness, implying that the latter is the result of the former.
The connection seems rather straightforward; by avoiding misdeeds, and specifically by going the extra distance to prevent illicit relationships from developing, a state of holiness is achieved. However, the verse is equating the state of holiness we are supposed to try to attain with G-d’s state of holiness; framing holiness it as “separating from illicitness” presents it as if G-d’s holiness is also a function of His “separating from illicitness,” something that doesn’t apply to G-d. Our holiness may be attained by building barriers to sin, but He is the essence of holiness. The two types of holiness cannot be compared, and our need to attain our type of holiness can’t be based on His totally different type of holiness. We are mundane beings, and have inclinations towards certain behaviors that must be avoided in order to achieve holiness; G-d does not have these inclinations, so His “holiness” doesn’t have a prerequisite of building protections to prevent base desires from interfering with spiritual growth. How can the verse be telling us to “be holy the way G-d is holy” by separating from illicitness, if that is not the way G-d became holy?
{You may have noticed that when I translated the verse, I included what seems like an extra comma after the second time the word “holy” is used, the one that refers to G-d being holy. Although it looks awkward in English, this is how the verse is broken up in Hebrew, with the word “for holy” being an expression in and of itself, followed by the expression “I am Hashem your G-d.” This seemingly unnatural pause may have been inserted to create an additional layer of separation between the holiness we can achieve and G-d’s holiness: (1) You should be holy, (2) for holi[ness is important, especially when trying to connect with G-d, Who is the epitome of holiness], (3) I am Hashem, your G-d, [who is holy, albeit not the kind of holiness humans can attain; yet, they can still connect with Me by removing themselves from base physicality]. Nevertheless, neither Rashi nor the Midrash make this point, merely explaining the verse as if there was no “extra” comma; you shall be holy since I (G-d) am holy, a comparison that doesn’t seem to work if our holiness is based on avoiding things that prevent holiness rather than being holy in its own right.}
Religion can serve numerous functions. It provides a structure to live life within, creates a social setting within which a community can be built, and develops into a culture based on these (and other) factors. [This is why it has been difficult to find a definition of “Judaism” that everyone can agree upon, as it means different things to different people.] From the Torah’s perspective, though, religion is not merely a collection of laws, or a means to provide community cohesiveness, but a lifestyle through which we can become better, more holy people. (It may provide those other benefits as well, but they are merely a byproduct of the program, not its primary purpose.) The difference between Rashi’s perspective on the commandment to be holy (creating barriers to sin) and Ramban’s perspective (minimizing even permissible pleasures) is therefore relatively minimal, as both are necessary to attaining real holiness.
If the focus was just the law, creating barriers to prevent sinning would only be necessary to minimize the chances of sin occurring. However, the goal is not merely to avoid sin, but to avoid being tempted to sin (even if the actual sin would not have occured anyway). The purpose of the barriers is therefore to prevent temptation from occurring in the first place, regardless of whether that temptation would have led to sin. (Although it is next to impossible to never be tempted, since the temptation itself runs counter to holiness, minimizing the occurrences of temptation maximizes the potential for holiness.) For example, hearing a woman sing may arouse certain feelings within men that infringe upon their ability to focus their attention on holy matters. It doesn’t mean that they will do something inappropriate, it just means that it can cause a reaction that runs counter to one of the primary purposes of Judaism, i.e. being (and becoming) holy. Therefore, included in the recommendations for men (recommendations that take the form of Jewish law, since the law is meant to foster this religious goal) is to avoid hearing women singing. This concept applies to avoiding situations where others are not dressed modestly as well. Even if most people cannot avoid walking tin areas where the standards of dress do not match the standards of our community, it is certainly beneficial for those who are fortunate enough to work within our community, and for everyone else during the periods of time that they are in their home community, not to have to fight distractions. Even if the difference in the amount of sinning is minimal, the not-so-minimal difference in the level of distraction, and in the amount of resources needed to avoid distraction, can make a big difference in the level of holiness that can be attained.
Obviously, G-d does not get distracted, and His “holiness” is not dependent upon building barriers to minimize distractions. But in order for us to try to attain that kind of holiness, we have to avoid such distractions. We are commanded to be holy because G-d is holy, and we are supposed to emulate Him in that aspect as well. And just as He is not tempted to sin, we should do whatever we can to not become tempted either. As the Midrash says (paraphrasing G-d), “just as I am removed [from sin], so should you be removed [from sin]. Therefore, we must build barriers that prevent sin not only to avoid sinning, but to avoid even those temptations that won’t get to the point of committing any sin.