This is a bit of a tricky question. Before speaking of historical views of homosexuality, it is very important to understand what is being spoken about. Prior to the 20th century, there really was no concept of homosexuality as we understand it today. In the late 19th century, the concept of homosexuality as an actual orientation was first proposed and referred to as 'sexual inversion.' (And that was in a book meant for mostly academic audiences, so it was decades before this became a widespread social idea.)
Prior to that point, there simply was no concept of homosexuality as we understand it. There were many groups which opposed homosexual ACTS, but these were mostly viewed as crimes like theft, murder, etc. While there were certainly people who preferred to commit these crimes more than others, just like there are career thieves and petty thieves, the idea that those people would necessarily oppose heterosexual relationships was unknown. Likewise, the idea that a person was unlikely to commit homosexual acts simply because they are involved in a heterosexual relationship was unknown.
Today we believe that homosexuality sets a person apart as a different KIND of person. It's not simply an act which anyone is liable to commit and which does not necessarily have wide-ranging implications about the person who commits it. It is important to keep this in mind when reading about historical attitudes toward homosexuality. Committing homosexual acts was seen as a moral failing, but not a systemic one.
So why was it a moral failing at all? It mostly comes down to incorrect understanding of the purpose of human sexuality. In ancient Greece, for example, sex was seen as a power display. Those who penetrated were more powerful than those who were penetrated. Most of our modern ideas about sexuality are inherited from ideas that first gained widespread acceptance during the Industrial Revolution.
The Industrial Revolution, and the fact it created a situation where adolescents were mostly no longer able to get a job which paid enough to support a family, led to widespread acceptance of the idea that bodily pleasure was destructive. In religious circles it was seen as impious, in secular circles it was seen as unhealthy. Basically any form of pleasure, including sexual pleasure, was seen as a potentially lethal weakness. People who were 'slaves to their passion' were seen as weak and corrupt. It all came down to productivity. Homosexual acts produced pleasure, but could not produce children. Pleasure was seen as a dangerous temptation, and failing to produce anything seen as a moral failure.
It is important to note that even during the Industrial Revolution, the time during which religious ideas opposing sex really took center stage (they existed previously but were like Catholic views on contraception today... simply ignored in most cases. Families slept, and screwed, in common rooms. Children grew up exposed to sex from birth and the lower classes at least saw no reason to prohibit child sex play so it was universal and that led to a whole life filled with sex. What else did the lower class have to do for fun?), their opposition was quite different from the opposition we see today. They had, as did every culture except modern western cultures, a category of human relationship which we have somehow managed to completely eliminate - platonic romance.
Platonic romances were romantic, but supposedly nonsexual, relationships between same-sex persons. Even married men and women were likely to have same-sex friends which they viewed romantically. They would exchange gifts, write love poems and songs for one another, pledge undying love, etc. When modern people read of these relationships they project modern ideas of homosexuality onto them which is really inappropriate and ignorant. They simply did not tie sex and love together the way we do. Sex was seen first as an entertainment, then as a lamentable necessity of the human animal.
Though not related to homosexuality, I feel it important to mention the view of sexuality prior to this. Development of agriculture had even more impact on how people viewed sexuality, and we retain some of those beliefs today. It was the birth of sex being seen as something which should be controlled. Unlike tribal situations, where children were raised amongst the entire tribe, once people settled down and started agriculture it became very expensive for a man to raise a child which was not his own. This motivated men to control womens sexuality. This started the idea that a mans spouse and children were property of the man. 'Deflowering' a mans daughter was seen as a PROPERTY crime. We still retain vestiges of this. When someone speaks of "saving myself", and otherwise uses economic language when speaking of sexuality, this is where it came from. They are "saving" their value for a dowry for their father.
Sources: 'Masturbation: The History of a Great Terror', Michel Foucault's 'The History of Human Sexuality', 'Good Sex Illustrated', 'The Sociology of Sex' course from The Teaching Company, ('Sex At Dawn', 'Sex At Dusk' always read together)