To be honest, it's not very clear here, but I would guess the meaning is: They are a burden on society, and this causes them pain, because they don't want to be a burden on society. Knowing they are a burden, makes them sad. It hurts their feelings.
Thus, in this context:
to their pain = and this causes them pain = which hurts them