This question already has an answer here:
Why do we ask god to inscribe us in he book of life? If whatever god does is for the best including when god removes someone from this world. We even have a custom when we hear that someone passed away we say, "Baruch Dayan ha'emet". If we believe that god does everything for the best then who are we to ask him to give us life? The same way he felt it was necessary to give us life he may feel it is necessary to take it away. Even great people and pious people receive "premature" death or even a form of seemingly kareit! If someone can bring a quote from a source of any Jewish text that could answer this question that would be awesome.