"Of all" refers to a noun's placement in context of its similar counterparts. In this case, "of all the ways to lose a person" emphasizes how in context of the other ways to lose people, death is the kindest out of all of them. You could also see this structure as "(out) of all the ways..."