Darwin developed his theory of evolution by natural selection based on observations made during his voyage on the HMS Beagle. He noticed that species varied between locations and over time, with fossils showing ancient species resembling modern ones. This led him to hypothesize that all species descended with modification from common ancestors over many generations, with natural selection driving changes by favoring heritable traits that increased survival.