A retired habitation is a help to the soul in avoiding distraction. For to have one’s life always mixed up with those who are fearlessly and scornfully disposed towards the exact observance of the commandments is shown to be harmful by the words of Solomon, who teaches us: “Be not a companion of an angry man, nor abide with a wrathful friend; lest thou learn his ways and get snares to thy soul.” And, “Come ye out from among them, and be ye separate, saith the Lord” points in the same direction.
Source: The Longer Rules, Question 6