In the modern era, we consider gay and straight to be separate categories. This distinction would have made little sense in antiquity. In ancient Greece, a powerful and influential man would often become the patron of a young man, teaching him about the world and having sex with him. This did not keep the powerful man from having a wife and often having a liaison with a slave girl or two as well. Greek gods (like Zeus) were happy to have sex with anyone, male or female.
The Romans, following the Greeks, were fairly open to what we would consider swinging both ways, at least among youths. A mature man, however, was supposed to rein in his passions, keeping a strict control over his body. Marriage, it was normally assumed, was between men and women, but the emperor Nero did marry another man. The joke in Rome, where Nero was widely reviled, was that it was too bad his father had not chosen a similar (male) "bride," for then he would never have been born.
Ancient Judaism, in contrast to paganism, taught that men were supposed to be sexually active only with women. The category of "gay" did not exist among the ancient Hebrews. (For that matter, neither did the category "bachelor." There were just men who were married and men who weren't married yet.) There did however exist what we would call gay sex, which was forbidden--strongly enough that one assumes it must have been going on.
Medieval Christianity did not worry too much about whether someone was gay. In part this was the influence of the New Testament, where Jesus has nothing at all to say about gay sex. And the Christians had quietly dispensed with major chunks of Jewish law anyway, including circumcision, taking multiple wives, prohibitions on eating pork or having a meat and milk dish, or even celebrating the Sabbath on Saturday.
In addition, the medieval church had much more to worry about than someone's sexual orientation. It has hard enough persuading people that they needed to baptize their children and avoid heresy and stop stealing the church's possessions. Add to this the constant low-level tension between monasteries and bishops and concerns like the Crusades and self-proclaimed prophets of the end of the world, and you can see why it was not a priority.
One could certainly be horrified at gay sex, but because it was not a clearly "bad" category, medieval men were much more openly affectionate with each other than are modern men who are afraid of being seen as gay. (My own grandfather stopped hugging his grandsons when they got to be about ten, saying, "We don't want to start to like it.")
Men routinely wrote each other letters, intended to be read out in public, saying how they longed to embrace and kiss each other. Richard the Lionheart and King Philip II of France became close friends, eating from the same dish and sleeping in the same bed. Richard's father, Henry II of England, thought this was wonderful when he heard about it, establishing good international relations, even though he had just sentenced some "catamites" for scandalous behavior.
The one place that really worried about gay sex was the monastery. But here the problem was not gay sex per se but rather sex itself. In an all-male community, straight sex wasn't even an option and thus not worth worrying about.
Interestingly, no one in antiquity or the Middle Ages worried too much one way or the other about lesbians. Presumably they existed then, but affectionate closeness between women was accepted as normal. One may note that the same is true of modern society.
Click here for more about sex in the Middle Ages.