The method of least squares helps to create the best-fitting line by minimizing the sum of the squares of the residuals, which are the differences between the actual and predicted values. By doing so, it provides the best linear unbiased estimation of the data points, revealing the underlying trend or relationship between the variables.