One major idea of Nazism (and fascism in general) is that all of the people of a country should conform to one, ideal, way of being. The society is strong when all people are alike, sharing in common goals and common values. The Nazis believed that it was important to maintain homogeneity in order to keep their country and society strong.
Because of this, they persecuted homosexuals. They felt that gays had an agenda that was different from that of society. They felt that homosexuals would form a separate society of their own, loyal to one another, thus weakening the overall society.
The Nazis also felt that homosexuals were weaker than other men. They worried that this weakness would infect their entire society. Since Nazism believed so strongly in the need for strength in their society, this was seen as a real danger.
For more details, follow this link.
Many people have posited that Hitler was covering up his own homosexuality with his policy concerning gays, but there's no proof he was gay. In Berlin, there was a sizable, active and evident gay population in the roaring '20s, including artists and bohemians. Hitler's ultimate goal was the establishment of a pure, Aryan race, and his policy advocated the elimination of "undersirables," primarily Jews, but also Gypsies, Jehovah's Witnesses, the handicapped and homosexuals.