While I am not fully aware of the actual history behind homophobia and its origin, I think I can shed some light on it. It's probably not necessary to know how it came from, because, chances are, people back then probably were not much different from the people of today in their way of perceiving and reacting to things. One does not have to look far beyond human nature to discover how certain adversities established between humans themselves came to be.
Just as how animals tend to behave hostile and wary of creatures that go beyond their familiar knowledge, our reaction to something we are not used to is not much different. Back in the days, sex for pleasure was considered wildly inappropriate due to the acts of adultery and what not resulting from it; sex was only deemed acceptable between a wedded couple to conceive their children. "Mating for kids" was certainly a form of behaviour that could be commonly seen in animals apart from human beings as well. Imagine how people of that period back them must have reacted when they were exposed to homosexuality. Two men having sex without a purpose, when even back then it was an obvious fact that a child can only be born between a man and a woman. Sounds pretty kinky, doesn't it? It also makes it sound like a choice; these two men are doing something that goes against their "survival instinct". It is a choice that deviates from the common belief, and so it has to be treated with some hostility and wariness.
It is, in a way, true, when an almost contradicting, unfamiliar subject is introduced to an already matured culture. Reflect back on the difficulty scientists faced during the period heavily driven by religious beliefs. Or when the aboriginal tribes were introduced to that of a Western culture during colonization period. The integrity of a community can be threatened when there seems to be a gaping hole in their cultural beliefs. For people to live together without constantly breaking out into fist fights and murderous acts, there must be rules and beliefs that people in the same community can see eye to eye about. So it is only natural that they would behave not exactly friendly to those that threaten the very beliefs that they have established together.
Nowadays, homosexuality is more or less a familiar subject in both physiology and psychology. Any legitimate scientists and psychologists would suggest that homosexuality is a perfectly natural phenomenon that can even be observed among other species as well. A specific cause for it is yet unknown, but more people know that being a homosexual is not a choice anymore.
In first world countries where freedom of speech and expression is respected, homosexuals were, albeit with much difficulty and prejudices, able to stand together and let others know of their existence. As the concept of homosexuality and its "culture" became better known, people felt less threatened by it. This is obviously a harder concept for more religious people to accept, because, while they are bound by their societal laws and regulations, they are also bound by their VERY traditional laws from their religion. It is also harder for people of older generation to accept this fact; I mean, have you seen a sixty year old trying to familiarize him/herself with the world of Internet? They grew up not really knowing much about homosexuality except for the prejudices made towards it, and radical things can be more difficult to accept for more mature group of people.
Recently, there have been many studies that homophobia is a widely popular concept among those that are insecure of their own sexuality. I mean, imagine an ex-alcoholic hanging out among a group of alcoholics getting themselves drunk and silly. As a person who is not very familiar or willing to accept his or her real sexuality, wouldn't he/she feel almost pressured among those who could easy bring out his/her not-so-proud side?
Well, I hope this has answered your question. Sorry for the long answer - I tried to cover as much as possible without being too vague. If you have any questions though, feel free to ask!