Pain is supposed to be a warning/avoidance system. Thog put hand near fire; Thog hurt. Thog remove hand.
But a good deal of internal injuries can’t be avoided, and avoidance of activities doesn’t promote healing. Take for example kidney stones. Thog get sharp pain in lower back. Thog roll around floor in agony for a few hours/days. Thog eaten by cave bear while rolling on floor. The same can be said for some sorts of cancers, etc.
Certainly, many internal pain sensations are useful. Pain receptors around broken ribs warn you to lie still for a few more days until you heal. But in general, internal pain doesn’t AFAIK give an advantage to the sufferer of the pain. Is there any evolutionary advantage that I’m missing here?
P.S. Yes, I’m aware that ironically, internal pain receptors are much more useful now, when we have medical techniques to deal with many internal problems. But that doesn’t explain their evolution.