Consciousness is the necessary knowledge aspect of the real-world system, necessary from the foundations of the world onwards, because existence does not imply knowledge of existence.
The existence of the particular and distinct categories, numbers, and relationships that underlie the real-world system does not imply knowledge of their existence.
These categories, numbers, and relationships are what identify the world: everything from particles to trees is identified, not all at once as whole particles or whole trees, but by their categories, numbers, and relationships in interactions.
With regard to human consciousness, people inevitably notice their personal inner feelings and sensations. But consciousness is not about the feelings, sensations, colours, emotions or thoughts: these are merely the forms in which conscious knowledge, of oneself and one’s surrounding world, manifests itself.
And, as noted above, the consciousness aspect of the world started small, with consciousness of the basic categories, numbers and relationships that underlie the real-world system. Human-level consciousness did not spring fully developed into existence ex-nihilo, just like human bodies did not spring fully developed into existence ex-nihilo: they were both built up out of smaller component parts. However, people have mistakenly tended to think that consciousness is either a suddenly-appearing high-level consciousness OR nothing at all.
Re "Why is there anything at all, why not nothing?":
Seemingly, there was no all-knowing consciousness at the beginning of the world, there was only knowledge of what had been created, i.e. the low-level categories, numbers and relationships, and the ability to further analyse that. There was no grand plan for the world, there was only the freedom to create, at the foundation of the real-world system.