Like all else: One small step at a time. DNA replication is NOT a perfect process, from time to time a "mistake" occurs. If the mistake is beneficial, it tends to remain in the population of organisms . If the mistake is harmful, it tends to be weeded out of the population. Thus, organisms drift one small copying error at a time, the beneficial errors collect, toward increasing success in the environment.