When my husband was trying to get a promotion in the company he is with, and he didn't get it when everyone thought he would, and with tons of praying on our part, we were very upset. Now my husband has a much better job with the company and the guy that got the staff job my husband wanted actually ended up taking a pay cut because of some of the changes in how they are paying staff. We could not have handled a pay cut.
My daughter and son-in-law were turned down for an apartment they would have had very small payments on because they made about $15 a year too much in gross income. They didn't understand why their prayers weren't answered, but they accepted it, and ended up in some other apartments. The apartments they were turned down for flooded a couple of months later.
If the person who died had continued living, he/she may have had to endure seeing their children die before them, had to endure alzheimers, may have been in a paralyzing car wreck, or any multitude of things that may have been so much more devastating than what they went through.
God knows what the future holds and he knows what is best for us. Like other people mentioned, the death of someone may have a great inpact on others, and even an echoing impact as they teach their children and grandchildren how this person fought a disease with dignity, then passed away without qualm, knowing they were going to a place with no suffering and no more disease. Their life (and death), may have even saved bystanders, including doctors and nurses who witnessed it.
This doesn't help much to answer why children are kidnapped and murdered, and other horrendous things that happen in this world, but when you see how things turn out, it is usually clear that God was in charge the entire time, and knew what he was doing.