Spiders belong to a large group of animals called the Chelicerata (kuh-LIH-suh-RAH-da). They are named for the snappers on their heads, their chelicera.
Some chelicera snap up and down, and some snap sideways. The other thing that animals in the Chelicerata group have in common is four pairs of legs.
Though that doesn't explain why they have four pairs of legs, does it?
Well, let's think about horseshoe crabs, which also belong to the Chelicerata group and are actually more closely related to spiders than crabs. They also have four pairs of legs. But they also have other leg-like appendages on their abdomens. (Appendages are things that stick out from the body.)
Horseshoe crabs, which haven't changed much for hundreds of millions of years, and spiders probably developed from the same ancient relatives.
But spiders lost those extra appendages. Spiders do, however, have a pair of appendages surrounding their chelicera.
These pedipalps (Pedi means foot ), help the spider grab food and shove it in her mouth.
Clearly the Arachnids (spiders, scorpions, mites and ticks, all of which are Chelicerates) are pretty successful. They've been around for millions of years and show no sign of disappearing. But the same could be said for insects.
In other words, six legs seem to work pretty well for insects, and eight legs seem to work pretty well for spiders and their relatives.
The reason we don't know more about spider evolution in general is that fossils of spiders are relatively rare. The first spider probably appeared around 400 million years ago. But try finding a fossil that old!
Scientists have found many less ancient spider fossils, many of them preserved in amber, which is hardened tree sap. More than 300 species of spiders have been described from about 40 million years ago.
However, these so closely resemble modern spiders that they really don't tell us much about spider evolution.
But back to the original question. We don't know exactly why spiders have eight legs. They just do. There is no WHY.