I've seen on a lot of websites that nail-biting behaviour is due to lack of iron in the blood. I'm wondering if is this actually true, or just an urban myth which has spread and spread?
There are two manifestations of iron deficiency that could explain this claim: koilonychia and pica.
Koilonychia or "spoon nails" is when the nail becomes concave. It can be a classic sign of iron deficiency on physical exam.* The nails of iron-deficient patients may also become brittle and/or split lengthwise.
Some form of pica is present in about half of cases of iron deficiency. It describes a broad range of eating disorders, often associated with mineral deficiencies, where a person will compulsively eat or chew on an unusual substance. Common examples are ice, clay, laundry starch, hair, and the classic, lead paint chips. However nailbiting itself has not been classified as a form of pica, possibly because it's so common among people without any nutritional deficit. Nailbiting (fancy medical word: onychophagia) is overwhelmingly attributed to anxiety, general compulsive behavior, or just being a kid.
So it's not inconceivable that an iron-deficient person with a tendency to put unusual things in their mouth and brittle, misshapen nails might start chewing on them. But it would be a fairly useless diagnostic sign because nailbiting due to other causes is so common.
*Koilonychia, like many "classic" signs, may be more common on med school exams than in real life.