The word utopia was first used in this context by Thomas More in his work Utopia; literally it means "nowhere". In this work, More sets out a vision of an ideal society. Other examples include Jonathan Swift's Gulliver's Travels, and B.F. Skinner's Walden Two.
For examples of dystopias, see George Orwell's Nineteen Eighty-Four, Aldous Huxley's Brave New World, any of William Gibson's novels.
A subgenre of this is ecotopian fiction, where the author posits either a utopian or dystopian world revolving around environmental conservation or destruction. Ernest Callenbach's Ecotopia was the first example of this, followed by Kim Stanley Robinson in his California trilogy. Robinson has also edited a collection of short ecotopian fiction, called Future Primitive: The New Ecotopias.
Another important subgenre are feminist utopias, for example Marge Piercy's novel Woman On the Edge of Time.