A least squares regression line is a standard technique in regression analysis used to make the vertical distance obtained from the data points running to the regression line to become very minimal or as small as possible.
For a least squares regression line, the sum of the residuals is always zero.
Basically, residuals are used to measure or determine whether or not the line of regression is a good fit or match for the data by subtracting the difference between them i.e the predicted y value and the actual y value, for the x value respectively.