I have struggled with the sort of question the OP poses for years, especially the 'premature' loss of a child, close friend or relative. Many people report that their life and outlook have been permanently changed by a 'close call' of some kind.
I have found Isaiah 57: 1 to be some comfort:
"The righteous perish,
and no one takes it to heart;
the devout are taken away,
and no one understands
that the righteous are taken away
to be spared from evil."
If you start with the premise that 'There IS a better place / state' (be it Heaven, Nirvana, Paradise or whatever), then perhaps it is easier to accept that death comes earlier to some people than to others.
Easy to say in the abstract; much harder to apply when it actually happens. I 'speak' from experiences.
I think that in the end, when things have come 'down to the wire', I have been more stirred by the ordinary human warmth, compassion, and (dare I say it) love of others than I have been by ideas, theories and theology. Though for a thinking being, these do have their place too.
However, if 'this life is all we have' then I can see entirely that early death, suffering etc will be totally abhorrent.
Many Christians, notably St Paul, would love to 'depart (right now) to be with Christ, which is far better', but accept that they have to stay here 'on earth' because [they believe] God still has a job for them to do here.
One can accept, reject, puzzle over or ridicule the idea, but it does seem to be a point of view held by a lot of 'believers'.