Objectively the purpose of life is simple, we're supposed to reproduce and protect our tribe so that they can prosper. Humans do this with technology and technology constantly changes in an upwards fashion which makes life easier and potentially can solve the question of "What's the purpose in life?". It probably won't happen for a long time unfortunately.
Spiritually you have to think about us coming into being, we have a clear path objectively from life to death, and that can be fully accounted for. However what's after death is unanswered by anything definitive. There are NDEs which seems to wrap around a person's belief systems and gives them a satisfactory answer to the purpose of life; however it's anecdotal even with so many cases(I'm bias towards NDEs). There are a lot of accounts that after we leave our bodies from the people who have experienced NDEs that they feel 'free' and that being in a body felt like they were nauseas with a lot of drawbacks.
Now there's Neville Goddard which had a strictly religious view and saw imagination as omnificent, which lies with god and being omnipotent and whatnot. He talked about Jesus and belief, prayers and the laws of attraction which your imagination can manifest if you focus on it. The way he died too is interesting. His view on life was simple "the purpose of life is to fulfill the word of god
" Here's one of his quotes.
"Consciousness is the one and only reality, not figuratively but actually. This reality may for the sake of clarity be likened unto a stream which is divided into two parts, the conscious and the subconscious. In order to intelligently operate the law of consciousness it is necessary to understand the relationship between the conscious and the subconscious. The conscious is personal and selective; the subconscious is impersonal and non-selective. The conscious is the realm of effect; the subconscious is the realm of cause. These two aspects are the male and female divisions of consciousness. The conscious is male; the subconscious is female. The conscious generates ideas and impresses these ideas on the subconscious; the subconscious receives ideas and gives form and expression to them. By this law-first conceiving an idea and then impressing the idea conceived on the subconscious-all things evolve out of consciousness;"
People define their own meaning in life, we always carve our own path even in our weakest moments where we're paralyzed. The only true equalizer is death.
My opinion on it is simple, we live and we die. We have the choice by our own hands to end our lives whenever we want; however that doesn't mean that it's a bad choice. If there's something I've learnt is that humans seem to attain consciousness, we don't have it, we're receiving it. That to me means that even if we die there's no death, it's just that there's a life after life.
If anything is certain about life, it's not the end goal but the journey and how it's placed you to where you are today. Believe in yourself no matter your actions, even in despair. I'll believe in you too.