Yeah but regrowing limbs arrived after, it's built on top of their tetrapod ancestry. So it's entirely possible that pain is still here as a leftover from when it was a very critical condition.
You can't regrow your finger, and having working fingers would've been useful for survival for nearly 100% of your ancestors (the ones that had digits, that is).
There are lizards who lose their tails painlessly as a way to escape predators. If they felt pain in that situation, they might die, so it would've been selected out over time.