Pain is a message in the brain. It says "this is bad!" so we can act and avoid something.
Pain lets us avoid damage. So animals with pain will have more offspring than animals without pain.
If pain distracts us from other activities then it reduces our ability to survive. So pain will on average not be distracting. But that is only an average: individuals will vary.
The universe is unpredictable, so some pain will be horrific and unacceptable.
If you are in extreme pain then obviously your top priority is to end that pain.
If you are not in extreme pain, but you have empathy for others then obviously your top priority will be to end their pain.
Since the universe is unpredictable, there will always be people (and animals) in extreme pain. So (if you have empathy) that will always be your top priority.