Let the blue line represent the function f with the constraint x^2 + y^2 = 1. See the yellow lines that barely kiss the blue lines? Those are going to be where the maximum and minimum values of the function occurs. Check this out. Those curves that barely touch our function, their gradient at that spot is going to be the scalar multiple of the gradient of our curve in that spot. This is how Lagrange Multipliers works.