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.
Why are we assuming we don’t have free will? We do. Its not total freedom, our freedom is contingent on existing circumstances, but hard determinism is easily disprovable.
The idea that there is no free will is a mind fuck that keeps you from questioning your reality. You might as well ask, “assuming the earth is flat, why does the stick disappear on the horizon?”
This is a nice and brief video that I’ve found persuasive. https://youtu.be/eELfSwqJNKU
Noone believes that people have full freedom with no context, no extenuating circumstances. What makes arguments like this seem convincing is how uncommon it is for people to think dialectically.
Here’s a very good essay that steps through all of the different parts of the problem, and looks at different views historically. https://www.marxists.org/archive/plekhanov/1898/xx/individual.html
To the hard deterministic explanation that “something always came before,” it asks “what is the role of the individual in history?”
This excerpt isn’t a substitute for reading the whole essay but it makes a point pretty concisely: