Charles Darwin developed the theory of evolution by natural selection after observing species diversity during his voyage on the HMS Beagle. He noticed that species on the Galapagos Islands had adapted to their environments in ways that increased their chances of survival, such as through variations in beak shape among finches. Darwin's theory explained how species evolve over generations through natural selection of inheritable traits best suited for an organism's environment.