When my best friend revealed to me that he had attempted suicide, and would certainly have succeeded but for being found a split second too soon, my initial response after the shock washed over was why? Because the expectation is ... "But you have something to live for, right?" The conversation was a long time ago now, but I probably said those words or some other paraphrase with the same meaning at some point. Because the conversation ranged from trying to understand exactly where he's at, which largely revolved around him explaining why he doesn't have anything to live for, me putting myself in his shoes as best as I can, trying to feel the pain and where it's coming from, then attempting to provide my perspective within that context, which is largely answering that question again but this time with a few yes's.
So as someone who has asked something similar when a suicidal friend revealed his secret, I suspect it's just a fairly natural query for a non-suicidal person. Also, given the gravity of the confession - in his case I was the only person he had ever discussed it with, he asked me never to tell anyone about it, and the only other person that knew he was suicidal was his mother who found him in time - it feels like it's on you in that moment to show this person life is worth living, and if you can't, they're going to die. And the way out seems to be finding a convincing answer to that question - so that's the direction we went, and I see you have encountered.
Incidentally, I didn't break my promise - don't be alarmed! Nor did my advice have any lasting effect. He ultimately followed through anyway. Unfortunately, I suspect that will be the most common result. Maybe it's for the best, who knows. But anyway that's my 2c on why the question comes up in that context.