Each group which the Nazis persecuted had also been persecuted to various extents throughout the history of Europe in general dating back to medieval times.
For example, antisemitism in Europe originally grew from the idea that the Jews were the people who murdered Jesus, and therefore they were a condemned people, cursed and kicked out of their homeland by God himself. By the time the Nazis came to power however, Jewishness was largely based on physical features and blood, which I explained yesterday in an answer to another question here.
As for the Roma, their persecution came down to the fact that they were nomadic and did not adhere to the concept of national borders and nationalism in general. Hitler was big on the idea of there being a nation for each group of people, "Germany for Germans, France for French" and so on. He also often used the same excuse to slander the Jews, calling them internationalists who would make Paris their home one day and Brussels the next.
It's also important to note that during the Nazi era, Jehovah's Witnesses were persecuted for something similar. Due to their stance of not pledging allegiance to any nation and their ban on military service, they were also sent to the camps. However, the Nazis viewed being a JW as something an individual could renounce, unlike being a Jew or a Roma. Therefore, if JW's signed a document renoucing their faith and agreeing to serve the Fatherland if necessary, they were free to go. However, many refused and were killed in the camps because of this refusal.
Homosexuals is an interesting one for the Nazis. They couldn't gather whether or not it was something you were born with or a learned behavior so they dealt with it on a case to case basis. However, Himmler did view it as a threat to the survival of the German race and believed that the race would gradually die out if homosexuality was not dealt with. He was particularly strict regarding homosexuality in the SS, partially due to the fact that it was commonplace within the SA during the early years of the party, and in a few cases SS men were executed for being homosexuals.
Interestingly enough, the Nazis always had a historical justification for their actions, and framed themselves as the saviors of the Aryan race. The common theme here is that every group of people who was persecuted was viewed to be a threat to the survival of the German race or incompatible with German values. In the Nazi view, in order for the Germans to survive, they had to openly fight all their supposed enemies.
Sources: Hochstadt, Steve. Sources of the Holocaust (New York: Palgrave Macmillan, 2004).
Goldhagen, Daniel. Hitler's Willing Executioners: Ordinary Germans and the Holocaust (New York: Random House, 1996), Ch 1-3.
Edit: Added the part about Jehovah's Witnesses