Plot study hours against test scores for a class and the points drift upward without lining up perfectly. Any line you draw misses each point by a vertical distance, the residual y−y^. Least squares chooses the line that makes the sum of the squared misses as small as possible. Squaring makes misses above and below the line count alike, and it punishes one big miss more than several small ones.
The best line has a short recipe. Its slope is b=rsxsy: the correlation r sets the direction and how closely the points follow the trend, and the ratio of standard deviations converts that to units of y per unit of x. Its intercept a=yˉ−bxˉ forces the line through the point of averages. If heights average 160 cm with sx=10, weights average 55 kg with sy=8, and r=0.75, then b=0.75×108=0.6 kg per cm.
The line measures only vertical misses because it is built to predict y from x. Predict height from weight instead and you get a different line, not the same one solved for x. The equation is also trustworthy only inside the range of x values in the data: a line fitted to children aged 5 to 12 can't predict an adult's height.
Not every line needs least squares. If two points are known exactly, such as (1,2) and (4,11), the slope 4−111−2=3 fixes the line and there is nothing to minimize. Least squares is for clouds of points that no single line passes through.
Think of it like this. Imagine each data point attached to a stiff rod by a vertical spring whose pull grows with its stretch. Let go, and the rod settles where all the pulls balance: close to most points, tugged hardest by the farthest. That resting position is the least-squares line. Like any rod, it stays straight, so it can't follow a curved pattern.
Core idea. The least-squares regression line is the unique line y^=a+bx minimizing the total squared vertical distance to the data.