It is impossible to overstate the impact The War of the Worlds by H.G. Wells had on science fiction. First published in 1897, this book broke new ground in science fiction - a genre still very much undefined at that time.
An alien invasion; monstrous creatures driving giant machines with long tentacles; weapons that blast an incinerating heat ray. These are now science fiction clichés. But they were original in the nineteenth century.
The War of the Worlds tells the story of a Martian invasion of Earth. Giant cylinders crash into England and strange creatures emerge. They climb into giant armored machines and begin to terrorize London and the surrounding area, killing people and destroying the cities. Although England was a world power at that time, it was no match for the weapons of the Martians. It isn't long before England's existing civilization is wiped out and humans are in hiding from their new overlords.
War of the Worlds is an adventure story, told by an unnamed narrator as he flees the invading monsters. The narrator does not save humanity. He simply observes and reports.
Wells was himself a scientist and he injects a great deal of science into his story - from how evolution affected the appearance of the Martians to how natural selection controls which alien plants survive on Earth and for how long to how gravity would affect the aliens. Even the final fate of the Martians is based in science.
This book is also a morality story. Wells repeatedly uses the analogy that the relationship of Martians to Earth Men is similar to our relationship with the animals of our planet, which we slaughter for food without thinking twice. He refers to us as ants to the Martians, thanks to their enormous head start in evolution, civilization, and technology. More poignantly, Wells compares the Martians' treatment of the British subjects to Britain's treatment of other people in its quest to expand its empire.
Read The War of the Worlds if you want to understand where much of today's science fiction originated.