Steampunk began as a literary subgenre of Science Fiction, essentially imagining what the Victorian Age would look like if -- for example -- Charles Babbage got his Analytical Engine working in the 1820s rather than having it fall by the wayside of history.
It's associated with the Goth Subculture through the fashion side of things; Cherie Priest, a noted author in the genre, has been quoted as saying that Steampunk is what happens when Goths discover the color brown.
You'll notice a lot of similarities between Goth fashion and Steampunk clothing -- in particular the proclivity of women to wear corsets on the outside of their clothes, as well as a high number of adornments. However, Steampunk is sometimes more accurately attached to the cosplay community as it's not terribly feasible to wear some Steampunk outfits in your daily life.