A mutation is a random change in the base sequence of the DNA of a gene. Most mutations have no effect on the phenotype, and some are harmful. Occasionally a mutation gives a new allele that produces a phenotype better suited to the environment. Mutations do not happen because an organism needs them.
Natural selection works in steps. There is genetic variation in a population. Individuals compete for resources such as food, space and mates, and more offspring are produced than can survive. Individuals with the phenotype best suited to their environment are more likely to survive and reproduce. They pass on their alleles to their offspring.
Over many generations the alleles for the suited phenotype become more common in the population. For example, in a sooty area, dark moths are hidden from birds on dark trees while pale moths are eaten. The dark moths survive and reproduce more, so the population becomes mostly dark. Individual moths do not change: it is the proportion of alleles in the population that changes.