Natural selection describes how a population, over time, adapts to its environment. Adaptation is based on the increased fitness of individuals carrying advantageous alleles that will, over time, increase in frequency (and conversely, less advantageous alleles will decrease in frequency). For example, let's say in a certain species of bird there is an allele that produces curly wing feathers. While these curly feathers may be nice to look at, they may not lead to an increase in fitness. On the contrary, these curly-feathered birds are likely poor flyers and they may not live long enough in the wild to reproduce, so they adversely affect the bird’s fitness. As a consequence, the curly-wing allele would not persist in the population because birds having this allele don't live long enough to breed and contribute the allele to the next generation.
Natural selection can only act on available phenotypic variation within the population. These phenotypic variants are reflections of genotypic variation, which arises from random mutations in the genome, through crossing over during meiosis, and from sexual reproduction itself through random fertilization. Also, natural selection can only adapt organisms to the environmental conditions at that time. If the environment changes, then the selective pressures may change and different alleles and phenotypes may be favored.
There are over 160 documented cases of natural selection occurring in wild populations. The peppered moth (Biston betularia) story is often used to illustrate natural selection. There are two forms of the moth: one mottled (light-colored) and one black. Under natural conditions, the mottled phenotype is more common because it mimics lichen on trees, so predators (birds) can more easily see and prey on the black moth. During the Industrial Revolution, soot from factories darkened the trees and poor air quality destroyed the lichen. This resulted in a shift of the phenotype frequency curve because the mottled phenotype became more visible to predators, and thus became the prey of choice for birds.
Natural selection acts upon the available phenotypes in a population, adapting them to their environment by increasing or maintaining favorable genotypes, so the individuals that are better suited to current conditions in the environment survive. For example, fairy shrimp have adapted to vernal pools (seasonal bodies of water that fill up in the spring and dry up in the summer). The shrimp complete their life cycle in as little as two weeks; hatching, breeding, and then dying. The eggs sit in the sediment until the vernal pool fills up again, and then they hatch and repeat this life cycle. In this way, fairy shrimp are well adapted to an environment that certainly would not be suitable for many other aquatic organisms.
Rarely does a single species live in a particular environment. Life is often a competition between species, and if one species gains an advantage ( through a new beneficial allele), then it often is at the expense of other individuals and species living in the same environment. This idea of a continuous race between species to be the most well adapted for a particular environment is referred to as the "Red Queen Hypothesis" (from a line uttered by the Red Queen in Alice in Wonderland; i.e., "Here, you see, it takes all the running you do to keep in the same place.")