LGBT Science Fiction and Fantasy Before 1970
While most overt portrayals of lesbian, gay, bisexual or transgender (LGBT) characters didn't appear in SF/F and H until after the early successes of the Gay Liberation Movement in the 1970s, that didn't mean that there was no depiction of homosexuality in genre before then. Of course, the majority of early L, G, B or T characters were coded, implicitly but not openly gay or bi. Homosexuality was illegal nearly everywhere and could carry severe legal and social consequences if it was discovered. Characters portrayed same sex interest with a significant glance, a passing comment or a bit too much interest in another character.
Early science fiction and fantasy writers who experienced what one of Oscar Wilde's lovers called "the love that dared not speak its name" and wrote fiction about it paid dearly for it. William Beckford, the gay author of the Orientalist fantasy The History of Caliph Vathek (1786), began his life as one of the richest men in England and ended as a bankrupt disgrace in France. A century later, Wilde himself, author of The Picture of Dorian Gray (1890), The Canterville Ghost and assorted fairy tales, would be imprisoned on sodomy charges and end his life a broken man.
In contrast, Sheridan Lefanu was able to write about a lesbian vampire in the classic vampire tale "Carmilla" (1872), but Lefanu was heterosexual and the lesbian relationship in his story is equated with death and destruction.
It would be another fifty years before bisexual author Virginia Woolf paved the way for subsequent positive portrayals of LGBT characters with her time travelling fantasy novel Orlando in 1928. In Woolf's novel, Orlando changes genders from male to female, then chooses to present as male for much of the rest of her/his four hundred year long life. Both men and women are attracted to her/him on multiple levels, making it a groundbreaking work for SF/F, though it is generally classified as literary fiction.
Author Olaf Stapledon's superhuman protagonist John Wainwright in Odd John (1936), also has positive relationships with both men and women before embracing asexuality. This was one of the more positive portrayals of homosexuality and bisexuality to appear during and shortly after World War II.
The negative portrayals, unsurprisingly, outnumbered the positive ones and generally equated homosexuality with Nazism. One of the better-known examples, Katharine Burdekin's alternate history about the Thousand Year Reich, Swastika Night (1937), is a vision of a Nazi society built around homosexuality and misogyny. Another alternate history, Sinclair Lewis' It Can't Happen Here (1935) touches on some of the same themes, linking homosexuality to Nazi totalitarianism.
The 1940s were, unsurprisingly, a bleak period for positive portrayals, corresponding with the overall attitude amongst pulp fiction editors and society at large that a character was better off dead than gay. Readers looking to find less dire fates for LGBT characters had to wait until the early 1950s when horror author Shirley Jackson included several female characters who can be easily read as lesbians or bisexuals in such novels as Hangsaman (1951) and The Haunting of Hill House (1959). Theodore Sturgeon cast a ray of hope with his classic story "The World Well Lost" (1953), about two aliens in love and the intolerance they face. It is considered to be the first open sympathetic depiction of homosexuality in science fiction.
The later 1950s and 60s ushered in more positive portrayals of LGBT characters by such famous names as Fritz Leiber, Theodore Sturgeon, Marion Zimmer Bradley, Edgar Pangborn and Robert Heinlein. The dramatic social changes of the 1960s impacted the science fiction and fantasy genres as they did everything else, inspiring a new generation of writers as well as creating new audiences. The decade also saw the early publications of the first openly gay and lesbian genre authors of the modern period, including Samuel Delany, Joanna Russ and Thomas Disch.
Their stories and novels, as well as those of other progressive writers in the field, paved the way for new perspectives on sexuality and gender in science fiction, fantasy and horror. If you're interested in learning more about the early years of LGBT SF/F, I recommend the excellent reference book Uranian Worlds: A Guide to Alternative Sexuality in Science Fiction, Fantasy and Horror, edited by Eric Garber and Lyn Paleo (G.K. Hall & Co, 1990) which covers the topic through 1989.
Some recommended reading (not mentioned above):
A Mirror for Observers by Edgar Pangborn (1954)
"Mr. Wilde's Second Chance" by Joanna Russ (1966)
"Aye, and Gomorrah" by Samuel Delany (1967)
"The Two Best Thieves in Lankhmar" by Fritz Leiber (1968)
Les Guérillères by Monique Wittig (1969)