Yep. Doing for others can keep pain at bay. It's all what you focus on.
And sometimes your pain causes you to be an example. And a witness. If my pain becomes a blessing to my kids, showing them how to have perseverance, and how to overcome - That is something that they may need later in their lives, and in ways you can't see right now.
One of the greatest things my folks taught me, was when they split. They lived apart for about a year, and tore the family up pretty bad... Their decision that their oath before God and their example to their kids - that the family was more important that their troubles (which were large) - It was that mindset that caused them to stick together and reconcile... And them healing that breach healed the breach in the family and made it so much stronger.
Pain is much the same way. It ain't your life. And your suffering has impact that you may not understand.