I used to be religious, and when I lost my faith it took me a long time to come to terms with death. But much of it comes from coming to terms with suffering. Pain doesn't hurt less, but I've found a place for it and am often grateful for it.
The pain from loss is part of what it means to love, which brings the gratitude.
I also hope we cure death! As tech advances we may one day be able to stop or reverse death entirely.