One of the earliest sci-fi works to really explore gender identity was Ursula Le Guin's The Left Hand of Darkness. It's about a cisgender man from Earth struggling to function as an envoy to a planet where the locals never really got into the whole "gender binary" concept.