This may seem controversial. I thought of this in the early 70s when I was trying to make sense of myself.
I realised that, since the basic structure of human society remained essentially the same, since the first societies, right up until WW1, there may be an answer there.
In human societies, especially settled communities, humans existed to fufill a role. The economic role is, of course, essential to any society, specialisation of skills, allows us to concentrate and perfect.
But there is an over riding role we were all expected to perform, that of defending the leaders, protecting and expanding their material wealth.
So, the males were raised to be warriors, while the females were raised to be nurses, providers and bearers of children. The Principal Purpose.
Those that failed to fufill their Principal Purpose were obstructive to the needs of the leaders for protection, of themselves and their wealth.
In some societies, some of these might form a clergy of sorts. A clergy performs a useful role by laying down immutable dictates, almost invariably to suit the interests of the leaders.
But those that are sexually non-conforming were labeled as being disruptive to the greater good of the community. Hence they were marginalised and rejected.
This might be the source of the hostility toward those of us who don't conform to the principal purpose.
The persistance of non-conformists, who seem to emerge, quite spontainously in every society and in every period of history suggests that the traits of gender and sexual non-conformists is innate in human society.
The tendency to persecute non-conformists would seem to be based upon a failure to recognise the contribution they make or for society to fail to provide opportunities to contribute