mostly the theories tie back to the theory of evolution from what I can see.
One theory about fingernails and toenails suggests that they are designed to protect the delicate nail bed. This supposition has been dismissed by many doctors, who point out that people who permanently lose nails develop tougher nail beds. It seems more likely that the delicate tissue or quick under the nail evolved in response to the presence of fingernails, rather than the other way around.
The more likely reason for the presence of fingernails and toenails is that they are useful. Fingernails help humans to scratch things, peel fruit, open things, pick away the outer layers of other edibles, undo knots, and perform a variety of other tasks. In a more distant past, fingernails probably assisted humans with the capture of body lice, as is still seen among the great apes. When the feet were used more like hands, toenails served a similar function, helping humans to open vital food objects, strip bark to build structures, and other such things.
Fingernails help the hands to grip things and start rips and tears. If you remain unconvinced of the usefulness of fingernails, try trimming them to the quick or covering them in tape for a day. Having fingernails out of commission makes it much more difficult to scratch itches, clean the hair and scalp, open foods, and perform a wide variety of delicate manipulations with the hands. Toenails may not be quite as useful, but when you imagine the feet as hands, their presence makes much more sense.
Like the hair, fingernails are made out of keratin, a type of protein. If the nails are weak and brittle, higher amounts of keratin should be ingested: a common source is gelatin, a food product derived from the hooves of animals, which also contain keratin. An increase in the level of keratin consumed will lead to healthier skin and nails.