Defence against predators
Since life is about reproduction, anything that keeps a creature alive long enough for it to reproduce will be selected for. The next generation comes from the fertilised eggs of the previous generation.