A residual is the vertical miss between a shown value and a fitted value. Squared error turns those misses into one exact quantity to minimize.
A trial line
For the trial line y=1 plus 1x, residuals are computed as actual y minus fitted y.
r=y−(1+1x)
Why squared error
Squaring makes every miss positive and gives larger misses more weight. The trial residuals are 0, 1, -1, and 1.
Summary
This trial line has residual sum 1 and SSE 3. Least squares will minimize that exact sum of squares.
∑r=1,SSE=3