Life’s purpose(biology) In the beginning there was simply a self-replicating process. There is not a whole lot to say about the details, because we still do not know how abiogenesis occurred. The formation and evolution of the first lifeforms is still unknown to us.
However it occurred in some way, and an object began to self-replicate. It didn't have a desire to live or think about self-preservation, it didn't even have a brain. It was just something that self-replicated via natural chemical reactions.
This self-replicating thing was a process. Many processes occur on planets that have a beginning and an end, like a storm or ice crystals forming and melting. But this process was able to keep on going via a replication process. Perhaps it continued doing this for days, months, years, or longer before anything else happened. But at some point, since there is only a finite amount of energy input into the system, it would not be able to continue to expand.
Since we don't currently know what exactly happened, this self-replicating process may have hit that boundary. Some random change(s) in the process occurred that were beneficial. It may have made the resulting replicators replicate more efficiently and started to more aggressively take up the energy, and the original self-replicators weren't able to keep up and were starved of energy.
But do keep in mind, that we have to be careful of the "pathetic fallacy". When I say "competing" that does not mean they were consciously trying to compete. And when I saw "aggressively taking up energy", that doesn't mean they experienced what we call aggression. It's like if someone says the "seas are calm" or the "wind is violent", that doesn't mean the seas actually feel the emotion of calm or wind is trying to be violent. We use this kind of emotional language all of the time to talk about things that do not necessarily feel emotion.
Nobody knows when lifeforms, these self-replicating chemical objects, experienced the feeling of "wanting to live". We do not know how physical matter generates experiences, to begin with. We do not know when lifeforms first had any "experiences" at all or became what we consider "conscious". We may use words that suggest emotion to describe such things, but that is just how we speak.