this is my .02$ worth on the whole thing:
You have two opposing forces, combined with a patriarchal model, conspiring to produce the kind of systemic "NO! NONE OF THE GAY!" antics normally seen in more conservative cultures:
1) Such cultures tend to be only a short stone's throw away from subsistence/agrarian living. The difference between prosperity and starvation often hinged on how many horrible screaming offspring you could spawn into the world to do dreary, back breaking farm labor for you. As such, being SUPER STRAIGHT and even TOXIC MACHISMO were considered boons.
2) It has been shown that the more male children a woman has, the greater the statistical odds of any subsequent male children being gay. (with each successive one producing increased chances of increased gayness.)
Which of course, means that the conditional setup for 1), produces LOTS OF GAY due to 2. Now, the setup.
3) Due to the highly dangerous nature of manual farm labor, and the disease risks often found with that modality of life, kids tended to die. They tended to die quite often. This made inheritance in a patriarchal hierarchy.... "Complicated"... when the next heir is totally more into Billy than into Bonnie.
This leads to at least 3 ways to deal with it:
1) Beat the living fuck out your gay kids, and tell them to be straight and marry a woman, and make babies so they can inherit the farm OR ELSE--
2) Outright fucking KILL your gay kids as soon as you discover that they are gay (which, through the simple desire to not be dead, results in gay kids following path 1, and being very unhealthy mentally), and bank on being able to bounce more crotch spawn out to inherit your massive ecosystem destroying herd of sheep/goats/cattle/other.
3) Challenge the normal inheritance model, so that a reproductively viable offspring is able to handle the continuance of the family lands and thus assure the future providence of your lineage. (not necessarily a male child even.)
Over time, option 3 gets exercised sufficiently often, especially as the impetus to have that patriarchal inheritance framework continue evaporates due to improvements in living conditions, and thus being gay becomes more socially acceptable/accepted. Before then, though- and especially in cultures that still have strong connections to that agrarian near-subsistence modality of function, options 1 and 2 dominate-- and they are not very nice to gay men.
Religion plays a role, but it really essentially comes down to a collectively-agreed-upon "Way things SHOULD BE!", and thus, as both incentive and excuse to justify taking options 1 and 2. The necessity of taking options 1 and 2 leads to the necessity to create a religion that demands it also, so that the people can feel "OK" with being that way to their own damn children.
There is of course, the inevitable evolution of a professional priest class, which then rides that wild bull with reckless abandon, and you end up with shit like the middle east.
The exception to the rule, is places like India, where historically there are "Third Gender" people, that are accepted.
SOOOO
Basically, the actual, real reason why some parts of the world are so down on your sexuality is:
If you are allowed to be openly gay, then their gay kids will want to be openly gay, and that will lead to family lands and possessions that have been passed down since the bronze age being subsumed by some other group, through failure of the inheritance model. (Also, their god, which they invented to provide societal support to enforcing this more, thinks gay is icky, and stuff.)
Basically, the family strong-man cant be gay. Its not allowed-- and cannot be allowed. As such, all gay must be not allowed.