There seems to be no ideal number of legs. Humans have two, dogs have four, insects have six and millipedes can have over 1,000. So what made spiders settle for eight legs?
"I think the best answer and the simplest answer is that spiders have eight legs because their parents did," Thomas Hegna, an assistant professor of invertebrate paleontology at the State University of New York at Fredonia, told Live Science. "But then that gets into sort of a regress, and somewhere this all had to start."
If we follow the succession of eight-legged spider parents back to about 500 million years ago, during the middle Cambrian Period, we arrive at the root of the chelicerate lineage, the group of arthropods that contains spiders. If we go even further back, to 541 million years ago, we find the ocean-dwelling lobopods, the ancestors of all arthropods.
The name "lobopod" doesn't refer to a single species but rather a large variety of species with rather simple bodies. Basically, they were wormlike creatures with segmented bodies. Each segment featured roughly identical pairs of short, stubby legs, and this pattern continued along the lengths of their bodies.
Related: What is the deadliest spider in the world?
As the lobopods evolved, they began specializing their legs and fusing body segments. The early chelicerates seem to have fused their small body segments into two big ones: the head and the abdomen. Scientists aren't sure why, but the head kept the legs, and the abdomen lost them. By the time spiders appeared 315 million years ago, they inherited a body plan that was likely already 150 million years old.
It's unclear which environmental pressures, if any, caused chelicerates to settle on their eight-legged arrangement. However, we know a great deal about where their legs came from — and it's weird.
"Those legs are actually part of their mouth," Nipam Patel, a developmental biologist and director of the Marine Biological Laboratory, which is affiliated with the University of Chicago, told Live Science.
Because spiders, insects, crustaceans and millipedes all evolved from an ancestor that likely had a segmented body with a set of appendages on each segment, these species are just highly modified riffs on that basic plan. According to Patel, all arthropod appendages — including legs, antennae and even mandibles (the jaws) — can be traced back to a stubby lobopod appendage.
Take a mantis shrimp. It swims with a bunch of little legs on a segmented abdomen. On the cephalothorax (a fused head and thorax) are its walking legs, and then near its mouth are little appendages that not only make up its jaws but also sweep food into its mouth to help it eat.
Compare that to an insect, whose abdomen doesn't have appendages. But it has six legs on its thorax, while its head and mouth are basically set up like the mantis shrimp's.
Then, there are spiders.
"If you look at a spider embryo, it looks exactly like an insect embryo," Patel said. "Except it only grows the legs on its head. But instead of using those as mouthparts, it uses them to walk."
The reason spiders walk with appendages from their faces goes back to lobopods and the original chelicerate body plan. While modern arthropods are spoiled for specialized appendages, the lobopods were wormlike creatures with many sets of roughly similar appendages.
Related: What is the largest arachnid to ever live?
"Initially, all of the legs were the same," Heather Bruce, a research associate at the Marine Biological Laboratory, told Live Science. "But then the first appendages became differentiated for being a sensory appendage, like for sensing and grabbing food."
Related mysteries
—Are daddy longlegs really the most venomous spiders in the world?
—Is every spiderweb unique?
—Why did trilobites go extinct?
From that point, the spider's chelicerate ancestors began to diverge from the other groups. In the ancestors of insects and crustaceans, the lobopod's multitasking front appendages lost their grabbing and feeding ability and became specialized sensory structures called antennae. But for chelicerates, those same appendages lost their sensory capabilities and became fangs.
Meanwhile, chelicerates' second leg pair evolved into a set of grabby appendages called pedipalps; the following four sets of legs remained in their role as walking legs, and all appendages after that were lost.
Well, not all of them. "Spinnerets evolved from spider legs," Bruce said. "There are really cool fossils in amber of a species that looks to be an ancestor of both spiders and scorpions, so it has some intermediate traits between the two. And on that fossil, there are very clear legs hanging off of the abdomen."