Why do children bite their nails?

It is best to intervene when these habits arise as they are harder to break the longer they persist.