There are two possibilities.
i) It might be that spiders have 8 legs for spinning a web or capturing their prey.
ii) It might also be that a spider's eight legs provide stable locomotion while walking on a web. In other words, stable locomotion on a web requires more legs than walking on the ground.
HOPE I HELPED :)