Most living organisms do not have two or four legs, but rather no legs, 6 legs, or more! Certain larger species have adapted to survive with fewer legs, due to the environment their species has lived in for thousands and millions of years.
Well humans and monkeys have two to walk on, because only one would be much more difficult, maybe even impossible. Then we have two more to use things and do stuff. Imagine how much you would be able to do with only one arm. Then cats and dogs and the like have four because they cant instinctively walk on two like us. Although some dogs are trained to walk on two, like i said its not programmed into their DNA, they have to be taugh to do it.