Natural selection is one of the basic mechanisms of evolution, along with
mutation, migration, and genetic drift.

Darwin's grand idea of evolution by natural selection is relatively simple but
often misunderstood. To find out how it works, imagine a population of
beetles:

There is variation in traits.
For example, some beetles are green and some are brown.

There is differential reproduction.
Since the environment can't support unlimited population growth,
not all individuals get to reproduce to their full potential. In
this example, green beetles tend to get eaten by birds and survive
to reproduce less often than brown beetles do.

There is heredity.
The surviving brown beetles have brown baby beetles because
this trait has a genetic basis.

End result:
The more advantageous trait, brown coloration, which allows
the beetle to have more offspring, becomes more common in the
population. If this process continues, eventually, all individuals
in the population will be brown.