My understanding is that conscious is a side affect of how memory works. Your conscious experience is essentially processing stimuli, connecting with existing memories, processing, and storing what is written to your “conscious” scratchpad.
Of course this is only one theory but I find it convincing.
https://journals.lww.com/cogbehavneurol/fulltext/2022/12000/....