Proof
$f:[a,b]\to \mathbb{R}$ continuous such that $f(a)\ne f(b)$. Points $x_1,\dots,x_n\in [a,b]$ where $f(x_1),\dots,f(x_n)$ are in the range of $f$.
Let $\alpha = \min\{f(x_1),\dots,f(x_n)\},\beta = \max\{f(x_1),\dots,f(x_n)\}$. Then the average value must lie between the minimm and maximum. By Intermediate Value Theorem, $\exists \zeta\in (a,b)$ such that
$$
f(\zeta) = \frac{f(x_1)+\dots+f(x_n)}{n}
$$
Suppose $f(a)=f(b)$. Let $n=2$, and $x_1=a,x_2=b$. Consider $f(x) = -(x+1)^2+1$ defined on $[-2,0]$. Notice that $\nexists \zeta \in (-2,1)$ such that $f(\zeta) = \frac{f(-2)+f(0)}{2}=0$.
This situation arises because if the function $f$ has the same value for its two end-points, but $f$ is not a constant and also not a function with oscillations, then we can take $n=2$ and the average of the value of the end-points is just the value of the end-point itself, which is not attained elsewhere in the function. If the function is a constant then the case is simple.