Our "mental awareness" is the product of evolution, taking place in a material universe where all elements are material ie matter / energy.
Not exactly random, though that comes into it. Random variations in a living thing that help it to survive long enough to reproduce are more likely to be reproduced in the offspring ie are more self-perpetuating. (And of course once humans are around to carry out programs of selective breeding of their animal and plant stocks, the random element is to some extent replaced,)
Besides energy, which is very important, there is also the concept of entropy. When early engineers were developing the first steam engines, for the early Industrial Revolution, they noticed there was missing energy. They would run experiments, do an energy balance for all the input and outputs to get efficiencies, and noticed that energy had disappeared. The term entropy was eventually coined to label this missing energy. It could be measured to know it was there (or not there) but what it was not yet clear how it happened.
This missing energy; entropy is now connected to the 2nd law of thermodynamics, which states that the entropy of the universe has to increase. This means the amount of missing energy, bleeding from the universe, is increasing with time.
The universe is bleeding energy. This energy is conserved; energy conservation, but not in a way that the material universe can readily use it. It is missing in terms of the material universe. Our material universe is aging and is running out of gas, albeit at a pace we can live with. The theories of a cyclic universe or a forever universe both violate the 2nd law due to the missing energy.
One key observation, about life and consciousness, is both life and consciousness constantly generate a lot of entropy and therefore both have a connection the universal mechanism, that is bleeding energy from the universe and stockpiling that energy somewhere else; energy conservation.
Life and consciousness is not based on a closed energy loop for the material universe, since that would be perpetual motion. Instead they have more of a connection to the missing energy stream that makes life and consciousness sort of like an energy vacuum that impacts it own future.
Since energy is being taken away, both life and consciousness need to change with time, since new paths are constantly needed to reflect the loss of energy, that sets up material and energy roadblocks compared to where it came. Evolution, life and consciousness is based on the 2nd law, with entropy and the missing energy being stockpiled somewhere else.
Consciousness ideas, like the after life, have an energy basis, connected to this stockpile of lost energy. While our life and consciousness, by adding to this stockpile, builds each of us a place there, based on how we generated that entropy.
Why entropy increases over time.
This section is more technical and is not needed for the main points. However, it will clear up questions with respect to how the above is possible.
In the free energy equation which is used for energy balances in chemistry and engineering, G=H-TS, G is the free energy, H is enthalpy which is a measure of internal energy like the amount of energy in a gallon of gasoline, T is temperature in degree K, and S is entropy.
The -TS term is why as entropy increases, the free energy of the universe lowers. As S gets bigger there is loss of free energy due to the minus sign. Temperature or degree K or Kelvin can only be positive, while entropy S can be plus or minus.
Since the term TS is the product of temperature and entropy, this product has the units of energy. Entropy, by itself, although coined as lost energy, does not exactly have the units of energy. T times S has the units of energy. S by itself is more like information, without the heat, attached to the lost energy.
When the universe first formed, it was extremely hot or T was at the extreme. As it cooled and continues it cool, even if you were to lower entropy, locally, since T has net decreased over the history of the universe, the original free energy lost, can never be fully retrieved. There is a stockpile of S but without the T that can make it available energy.
There is lingering entropy or lingering information about the lost energy, but this information is not in a state needed to make it useful to the universe for extracting energy. The pool of lost energy is not exactly in the form of energy, as we know it, but rather is more like information of what was, but which cannot be net reclaimed due to our universe cooling. It has existence, but not a clean path for energy recycle. It has it own properties and its own unique place that runs parallel to our material universe. the Bible has the heavens and earth forming at the same time; entropic and material.
When we use particle accelerators, we add a lot of energy and are able to reverse entropy at extreme conditions; extreme T equivalent. We can extract some of this lost energy, but at a high up front energy costs. This is not a net gain since entropy will still net increase. However, it can result in temporary exotic states of matter, due to the summation of these two energy streams; input and entropic. Then the 2nd law take over and we lose energy again; exotic state decays.