Consider the auxiliary function
$$g(x):={f(x)-f(a)\over x-a} \quad(a<x\leq b), \quad g(a):=0\ .$$
Then $g$ is continuous on $[a,b]$ and differentiable in $(a,b)$. One computes
$$g'(x)={(x-a) f'(x)-\bigl(f(x)-f(a)\bigr)\over (x-a)^2}\qquad(0<x\leq b)\ .$$
If $g(b)=0$, then this is a consequence of Rolle's Theorem.
If $g(b)>0$, then $g'(b)<0$; therefore $g(x)>g(b)>0$ immediately to the left of $b$. This allows us to conclude that $g$ assumes its maximum on $[0,b]$ in an interior point $c$. From $g'(c)=0$ it then follows that
$${f(c)-f(a)\over c-a}=f'(c)\ .$$
The case for $g(b)<0$ is similar.