The brain evolved to be intelligent. Intelligence is the ability to model the outside world in order to make predictions and then choose an optimal course of action. More intelligent beings are generally more "fit" in the evolutionary sense. Hence how humans have conquered all the ecosystems on the planet.
Turns out, consciousness/experience/qualia is an unexpected side effect of this process. We can "feel" the intelligence happening.
Where we humans get lost is believing that it has any meaning, or that we are somehow in control. We're not; the feeling of free will is just a other trick of qualia.
We don't know that either. We may be a collection of interacting consciousnesses arising from different organs that all pass around the baton called "I".
There's a lot of nerves and bacteria in the digestive system that might contribute some of it. That and various hormonal glands and reproductive systems.
Turns out, consciousness/experience/qualia is an unexpected side effect of this process. We can "feel" the intelligence happening.
Where we humans get lost is believing that it has any meaning, or that we are somehow in control. We're not; the feeling of free will is just a other trick of qualia.