why octopus have 8 legs?
Because if it had ten legs it would be a decapus not an octopus. Having eight legs appears to be a fairly common number. It is symmetrical (which is usually a favorable trait) and has some amount of redundancy. It also allows for a high level of dexterity and strength.