There are many theories about why humans have fingernails and toenails. Most relate to human evolution, suggesting that they are related to the claws that other members of the animal kingdom have. Fingernails especially are highly useful to perform daily tasks, and toenails sometimes come in handy as well, depending on the situation. While nails may be vestigial remains of humanity's wild past, most people who have lost nails agree that they are much more valuable than they look.
One theory suggests that they are designed to protect the delicate nail bed. This supposition has been dismissed by many medical professionals, who point out that people who permanently lose their 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 is that these structures 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, they 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. Having them 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 a person imagines the feet as hands, their presence makes much more sense.
Like the hair, nails 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, which will serve the user better for daily tasks. Nails should also be well cared for: the cuticles should be kept trim and the area underneath the nail before the quick should be scrubbed to eliminate accumulated dirt and bacteria that collect there during the day.