How is natural selection related to phenotypes and genotypes?
It is very important to note that natural selection works directly on phenotype, not on genotype . This is why population of biological organisms fail to attain optimal fitness.
If a particular phenotype helps an organism to survive better and reproduce in higher rate then that phenotype gets selected. For example, malarial organisms fail to complete erythrocytic part of its life cycle in RBCs present in blood of carriers of sickle cell anaemia. In Africa, such heterozygous carriers are getting naturally selected for thousands of years because they are naturally immuned against dreaded malaria.
This in turn has led to a condition in the gene pool where an undesirable recessive gene of sickle cell anaemia still persists in large number. This is often described as the genetic load : presence of undesirable genes in gene pool.