Well, evolution is more of a result, not a cause. It's pretty much just about math. Every individual gets killed off at some point, but genes live on. If the gene had some function that improved the reproductive success of the individual (stronger immune system, better protection against predators etc.) to a point where it produces more offspring than the average, then that gene will become more common within the population. Even if everybody reproduces, some individuals are going to be better at it.