Three possibilities come to mind:
Is there an evolutionary purpose?
Does it arise as a consequence of our mental activities, a sort of side effect of our thinking?
Is it given a priori (something we have to think in order to think at all)?
EDIT: Thanks for all the responses! Just one thing I saw come up a few times I’d like to address: a lot of people are asking ‘Why assume this?’ The answer is: it’s purely rhetorical! That said, I’m happy with a well thought-out ‘I dispute the premiss’ answer.
I don’t believe there is an “illusions that we have free will,” either. Honestly, “illusions” don’t really even exist as they’re traditionally talked about. People say if you place a stick in a cup of water, there is an “illusion” created that the stick is bent. But is there? What you see is just what a non-bent stick looks like in a cup of water. Its appearance is different from one out of water due to light refraction. It’s not as if reality is tricking you by showing you a bent stick when there isn’t one, that’s just what a non-bent stick in water really looks like.
The only “illusion” is your own faulty interpretation of what you are seeing, which upon further inspection you may later find it is wrong and change your mind. There was simply no illusion there to begin with. Reality just presents itself as it actually exists, and it is us who interpret it, and sometimes we make mistakes and interpret it wrong. But it’s not reality’s fault we interpret it wrong sometimes. Reality is not wrong, nor is it right. It just is what it is.
In a similar sense, there is just no “illusion of free will.” Neural networks are pattern recognition machines. We form models of the external world which can approximate different counterfactual realities, and we consider those realities to decide which one will optimize whatever goal we’re trying to achieve. The fact we can consider counterfactual worlds doesn’t mean that those counterfactual worlds really exist, and indeed our very consideration of them is part of the process of determining which decision we make.
Reality never tricks us into the counterfactual worlds really do in some way exist and we are selecting from these possible worlds. That’s just an interpretation we sometimes impose artificially, but honestly I think it’s exaggerated how much of an “illusion” this really is. A lot of regular people if you talk to them will probably admit quite easily that those counterfactual worlds don’t exist anywhere but in their imagination, and that of course the only thing real is the decision that they made and the world they exist within where they made that decision.
Hence, reality is not in any way tricking us into thinking our decisions somehow have more power than they really do. It is some of us (not all of us, I’m not even convinced it’s most of us) who impose greater powers to decision making than it actually has. There just is no “illusion of free will,” at best there is your personal misinterpretation of what decision making actually entails.
Thanks for the response! Would it change your answer at all if I had instead asked, ‘Why do we have the idea that we have free will?’