
Since $f$ has a local extremum at $x_1$, then surely the LHS of equation (3) always zero? If so, then isn't lambda always simply zero too? But this cannot be, otherwise the last sentence of the theorem wouldn't be phrased the way it is. What am I missing?
It's not $f$ that has a local extremum at $x_{1}$, but rather $f|_{S}$. Consider, for example, $f(x,y)=xy$ restricted to the line $y=1-x$. This restricted function has a local maximum at $(\frac{1}{2},\frac{1}{2})$, but the full function $f$ is not at an extremum at $(\frac{1}{2},\frac{1}{2})$.