Humans feel pain to keep them safe. I know this sounds crazy but pain lets us know that we are in danger and there many be an injury damaging our cells. By having a strong reaction to this danger helps motivate us to get away from it or get help (like medicine). There are some people that have a very rare genetic disorder than prevents them from feeling pain. They get many injuries without feeling anything so they can get very sick or hurt without realizing it.
Long-term pain is not usually very helpful to the body. We don’t know for sure why some pain continues after the damage to cells stops. This is an important area of research.