Homosexuality most likely existed even in the ancient rabbinic communities. The rabbis were undoubtedly familiar with Greek and Roman culture, where homosexuality was considered a perfectly acceptable lifestyle. 
Although the Sages worried about their students sexually acting out, they pragmatically suggested that if one could not control one’s sexual “appetite,” he should wear dark clothes and go to a place where nobody knows him and do whatever his heart desires, “rather than profane the name of Heaven openly.”
Traditional commentaries tend to think the rabbis are referring to heterosexual sex, but this assumption is unwarranted. How do we know that the rabbis were not also alluding to homosexual lay people, or perhaps more specifically–scholars?! A person’s sexual appetite surely is not limited to just those looking for heterosexual sex, and this point ought to be fairly obvious. In Talmudic times, the Sages knew they could not realistically micromanage their followers or especially their colleagues; they feared that the greater the scholar, the greater likelihood would be his disgrace.
It seems to me that the rabbis feared that a homosexual scholar might prove to be a source of embarrassment and scandal if he acted out his urges within the local community. Regardless of the specific context, one thing seems fairly clear: there are people who cannot or will not control their libido–regardless of their sexual preferences. For such people, the rabbis offered a practical way out so as to preserve their community’s dignity.
One suspects the Sages chose not to elaborate on the details of wearing dark clothes since it might convey the impression that homosexual behavior might be perceived as a de facto approval of a forbidden lifestyle.
Although the medieval scholars never considered such an interpretation, our modern understanding of human sexuality demands that we take this possibility into serious consideration.
 Plato writes in the beginning of the Symposium, “I know not,” says Phædrus, ” any greater blessing to a young man beginning life than a virtuous lover, or to the lover than a beloved youth. For the principle which ought to be the guide of men who would nobly live–that principle, I say, neither kindred, nor honor, nor wealth, nor any other motive is able to implant so well as love.
 BT Mo’ed Katan 17a; BT Kiddushin 40a.
 According to R. Hannael (Morocco, 9th century) as well as some of the Tosfot scholars (cf. BT Mo’ed Katan 17a), refuse to believe Rabbi Ilai actually gave tacit approval to these would-be sinners. Rather, the Sage felt that if the student or a layman were go to another place while wearing dark clothes, his libido might subside. As to why this is so, neither R. Hananel or Tosfot offer an explanation for their interpretation. On the other hand, Tosfot in Hagiga 16b seems to uphold Rashi’s more literal reading of the Talmudic text and contends that R. Ilai’s remark means exactly what he says (cf. BT Hagiga 16b, Tosfot s.v. Vyeaseh). Anyone reading the Talmudic passage would have to agree with Rashi’s interpretation because it makes more sense.