In most of Europe at least, homosexuality could not be openly practiced for most of the middle ages. There were certain exceptions, but it was not generally considered acceptable, and it was persecuted by the church or other moral authorities, at the very least as ostracism if not outright legal punishments - usually seen as a deviant sexual act, which were also routinely punished. Since the states were far weaker than modern states, it wasn't as systematic and universal as the Nazis attempted, but it was still happening.
Even in societies we perceive as more open such as ancient Rome, homosexual acts were often not explicitly accepted as normal, except for some we today would (rightly) consider abhorrent - adult men having sex with teenagers, but never the other way around.
For anyone else wanting more context, this is an ok starting point: https://www.artofmanliness.com/people/relationships/the-hist... (but note that the side of the story from inside the gay community is yet another matter, as niom hints at)
Basically, before most people knew that "gay" was a thing, there was much less pressure on men to be performatively straight.