Living organisms are examples of dissipative systems, like a wind-Zephyr, or the Red Spot storm on Jupiter. This general category, involves emergent structures that are sustained by their accelerating a transition from unlikely ordered states, into likely disordered states. This is part of the universe sponteneous tendency to iterate towards increased disorder, which we call the Second Law of Thermodynamics (Conformal Cyclic Cosmology provides a plausible idea how this could be getting reset). Highly ordered or maximally disordered systems tend to be boring, the interesting place is the transition between, described by complexity theory, and the domain where emergence happens.
Life is the subset of dissipative sytstems that create local patches of decreased entropy, at the cost of increasing entropy outside the organism so a net acceleration in increase of entropy - through respiration and eating, for instance. The Gibbs Free Energy is a useful way to understand how living systems don't just 'roll down the hill' of entropy, but find jumps of harvestable energy that can be used to power metabolic processes. See this Mindscape episode: Kate Jeffery on Entropy Complexity & Evolution.
Life seems to have begun at 'white smokers', gas vents in alkali mud, where polarised molecules that are present sponteneously form spheres, that have different chemical conditions inside than outside, a recipe for energising dissipative complexity. An RNA soup gathering in these spheres, formed replicating systems that propagate specific molecules, and then whole ecologies of molecules, energised by chemical gradients between the inside and outside of the cell. Mitochondria and the cell nucleus seem to have begun as parasites, that became obligate symbionts, and supported an explosion in the complexity of life. See Are Life and Intelligence analogous? for discussion.
We can map the entire neural system of one of the simplest organisms, and we find it has 1 out of it's 302 neurons dedicated to distinguishing self from not-self, which has obvious advantages in not eating it's own body. That seems to be the origin in more complex organisms, of touch. Evolution has a pattern of 'hijacking' one thing for another, like human ear-bones are the descendent of fish jawbones.
The brain being split into hemispheres, seems to be about maintaining parrallel processing of the world for each side of our body, but with one having an internal emphasis, and one external (see cerebral hemisphere and hemispherectomy). This can be understood as extending self vs other.
Intersubjectivity, our capacity to see the point of view of others and invite them into our own, can be understood as being rooted in mirror neurons as specialised neurons in neuronal structures for mimicing other humans. And extended by the neocortex, which the Dunbar Number indicates developed for understanding the intentions of others and navigating our social landscape not for generalised problem solving - this can be associated with the Default Mode Network, and the maintenance of the social self.
Self-consciousness having this special significance we alot it, is I think best understood in terms of Hofstadter's strange loop model, and tangled hierarchies. That is, that cognitive maps which include a self-model that can be altered towards generating desired outcomes, produces feedback loops that involve intentionality, including as applied to what kind of being to be or become. Crucially we can relate this to actual predictions about the role of intelligence, as Kahneman's system 2 editing system 1 responses; discussed here: Is AI capable of Hofstadter's anology? This can also help deal with Godel Incompleteness and Turing's Halting Problem, because it allows a function being executed to become a unit in a new metaphor, setting an unhalted algorithm into a coherentist fabric rather than getting stuck. It may look an obvious thing to be able to do, but this is a crucial faculty distinguishing minds from computers, as highlighted for instance in Penrose's The Emperor's New Mind.
So we have a ladder, from entropy, to inside and outside, to a social self, to intentions and active self-awareness that decides what kind of person to be.
Universal Constructor Theory is a new approach being developed to help reconcile aspects of fundamental physics, information theory, and Darwinian-style evolution, namely how a 'dead' system can accumulate information about it's environment such as to help it achieve homeostasis and replication. In it the capacity of simple systems to have constrained sets of permutations, but which one it's in being uncertain, is understood as a generalisable and fundamental property of systems. See Constructor theory of life
Some other relevant answers: