On Wikipedia, it says
If $X_{i};i=1,\ldots ,n$ are independent normal $(\mu ,\sigma ^{2})$ random variables, the statistic
$$\frac{\sum\limits^n_{i=1}(X_i-\bar{X})^2}{\sigma^2}$$
follows a chi-squared distribution with $n − 1$ degrees of freedom. Here, the degrees of freedom arises from the residual sum-of-squares in the numerator, and in turn the $n − 1$ degrees of freedom of the underlying residual vector $\{X_{i}-{\bar {X}}\}$.
With that in mind, I'd like to put forward the following example:
Suppose we choose an integer, $10$. Let's say our goal is to choose some $n$ values that sum to $10$. Let's say $n=3$. I freely choose $6$ and then $3$, but now I am forced to choose $1$. Hence I have $2$ degrees of freedom. Or more generally, $n-1$ degrees of freedom.
In this example, it's clear that the final choice is not a free one, because we have some target value, and so once we've made $n-1$ choices for the summands, there is only one possible value that ensures we satisfy the target sum value constraint.
Now, going back to case of the residual sum-of-squares on the numerator. If this were $\sum\limits^n_{i=1}(X_i-\bar{X})$ instead (notice I've dropped the square), then our target is $0$. So again, like in the example above, we have $n-1$ degrees of freedom because we can make free choices for $X_1\ldots X_{n-1}$, but then $X_n$ is forced. However, once we square each $(X_i - \bar{X})$, we lose the target value of $0$.
So how do we know that the degrees of freedom is $n-1$ without a target value? If there is no target value, why are we not able to make $n$ free choices?