The X-Men supposedly is an allegory that symbolises the struggle of minority groups in general. This includes gay people. But I don't know what minority groups the creators had in mind. They may not have been thinking specifically of gay people. There was McCarthyism in the USA - McCarthyism took place during a period of intense suspicion in the United States primarily from 1950 to 1954, when the US government was actively countering American Communist Party subversion, its leadership, and others suspected of being Communists or Communist sympathizers. During this period people from all walks of life became the subject of aggressive "witch-hunts," often based on inconclusive or questionable evidence.
And of course there was the racist events in the USA too. And the civil rights movement that led to the protests led by Martin Luther King and the passing of the Civil Rights Act in 1964. It was in 1963, the year the X-Men was first published, that Martin Luther King said: "I have a dream that my four little children will one day live in a nation where they will not be judged by the color of their skin but by the content of their character" in a speech at the Lincoln Memorial, Washington D.C. (28 August 1963).
During the 60s there was also a rising gay rights movement in the USA that led to the Stonewall Riots of 1969.
So the X-Men was created in a time where social/political minority groups - in particular blacks, gays and Communists - were fighting for their rights in a time of persecution. Although Communists are not born different - it's a political choice - they were part of this climate of discrimination, fear and suspicion.
In the X-Men universe, the scientific term mutants is applied to those born with unusual abilities (and/or appearances) just as many people believe there is a 'gay gene', although I don't know whether there were strong scientific thoughts about a gay gene at the time the X-Men was first created.
The persecution element and the fight for rights is present in the comics in a very powerful sense, and has been reinforced by the movies. The movies contain what could be interpreted as several ideas that have particular resonance with gay people - running away from home (Rogue), the search for true identity (Wolverine), fear of what normal people might think (Storm, in her conversation with the dying Senator Kelly), fear of taking part in normal life because they may be shunned or bullied (Mystique in her conversation with Kelly on the helicopter). And Magneto's Jewish/gipsy parents being led to the gas chamber (as gay people also were). Also, Iceman's 'coming out' scene with his parents in X2 has been seen by many as having a strong gay subtext.
Bryan Singer - who is gay - was attracted to the movies by the idea of persecuted minorities. He is also Jewish and as an adopted child is also searching for his true identity -- which is why he focused on, and identified with, Wolverine in particular.
Ian McKellen was attracted to the X-Men movies by its symbolism for struggling minorities. And Singer said he would often direct McKellen with a gay reference. In an interview in Total Film magazine (issue 44, September 2000), Singer was asked how he got the actors to find their characters (they were not allowed to read the comics), and he responded: "You find tricks and ways of getting them to speak, or intellectually: 'Look, Ian, this is a society of people who want to wipe out homosexuals. What do you feel about that?' There's ways to do it."
In the same interview, Singer says: "The idea about reluctant superheroes, born the way they are, searching for acceptance in a world that hates and fears them, it's interesting. It's what every adolescent experiences at one point or another. It's what I experience every day."
Producer Lauren Schuler Donner said in the same magazine article: "Thematically there's a lot to relate to. It's about oppression. It's about prejudice, it could be the Jews in World War Two, it could be gay people."