Praise be to Allah.
The doctors say that the phenomenon of nail biting among children is connected to psychological problems. If you have had this problem since you were small, then we advise you to consult a psychologist whom you trust with regard to his religious commitment and knowledge.
From the point of view of sharee’ah:
Islam brought the best of attitudes and habits, and forbids bad attitudes and habits. This habit – nail biting – is disliked by most people and they regard it as a bad habit. This is in addition to the physical harm that it may do, because of the dirt that collects under the fingernails and the damage that this may do to the nails and teeth.
Hence you should make yourself stop this habit. That may be difficult in the beginning, but you will get used to it and it will become a habit after that. This is the case with all good attitudes that a person can make himself do until they becomes a habit and second nature for him. As the Prophet (peace and blessings of Allaah be upon him) said, “Knowledge comes by learning and patience comes by making oneself be patient.” classed as hasan by al-Albaani in Saheeh al-Jaami’, 2328.
And Allaah knows best.