Understanding the least squares regression formula? 
I've seen the following tutorial on it, but the formula itself had not been explained (https://www.youtube.com/watch?v=Qa2APhWjQPc).
I understanding the intuition behind finding a line that "best fits" the data set where the error is minimised (image below).

However, I don't see how the formula relates to the intuition? If anyone could explain the formula, as I can't visualise what it's trying to achieve. A simple gradient is the dy/dx, would't we just do $\sum(Y - y) \ ÷ \sum (X - x)$ where Y and X are the centroid values (average values). By my logic, that would be how you calculate the average gradient? Could someone explain this to me?

very concisely:   


*

*if the points were all on a straight line, then you would like that to be the regression line, isn't it ?   

*if now you translate rigidly the linear cloud (no rotation),  you would like the regression line to translate in the same way;   

*the regression line will contain all the cloud points, including the centroid $(\bar x, \bar y)$;

*passing to a general cloud of points, translate the reference system to have the origin at the centroid and see what happens to the parameters $m' , c'$ computed in the new reference. 
