For example in the UK, same sex relationships were seen as unnatural in the past and were illegal. I don't think it's as simple as there are males and females and that's it.
Is there a logical connection between these two sentences, because I'm not seeing it? Prejudice against those who are same-sex attracted is totally different from people with gender issues. The two issues have been coupled together in spite of having little common ground. This has been detrimental to many gay men and especially lesbians because they are now told that their sexual orientation should relate to gender identity, not sex, and that leads to lesbians told it's bigoted not to consider dating transwomen, who are male. Spot the difference from the old trope that a woman identifying as lesbian just hadn't met the right man yet.
Biologically, right across all the mammals there really are just males and females, and that's it. Some people (a very small number) have disorders or differences of sexual development that make it difficult to observe at birth what sex they are, or later on they don't go through puberty in the way that would be expected based on their outward appearance. These are medical conditions. From the point of view of sexual reproduction, there are only two gametes, eggs and sperm, and humans (and all the other mammals) have bodies arranged around producing one or the other. No healthy human has ever been able to produce both gametes.
Socially, every society has some degree of sexual stereotyping. Some people struggle with this. The answer there is not to agree they must really have the wrong body to match their brain - what would that even mean? The brain is part of the body. We should be fighting the stereotypes.