I suspect we gained the ability to think about the minds of others before we ever applied that ability to becoming conscious of our own minds.
First, some animals gained the [unconscious] ability to think about the motives of others.
At some point, they gained a sort of proto-consciousness of others’ minds by hallucinating that the others had supernatural selves, which would appear to speak or demonstrate what the hallucinator “thought” was going on in the minds of the others. This enabled communication within the mind of a thinker, without the thinker knowing it was thinking, or yet having “first-person theory of mind.”
The next step was hallucination of one’s own supernatural self, which could then be seen as the agent of one’s thoughts. This sense of agency created the first psychological sense of “will”, and of “free will”.
Interestingly, a very large share of the population (at least here, in montana) seem to have still only applied this sense of agency to a very small percentage of their thoughts. The conscience is still seen as “other”, the unconscious is still seen as “other”, and, of course, intuitions or internal “nudges” which they regard as coming from God or from angels or demons are still seen as coming from “others.”
But this whole process of gaining any sense of agency over thoughts and imagination may have required an hallucinatory supernatural sense of self to first “spontaneously” emerge from the unconscious—sort of the “key hallucination” that made conscious imagination possible.
