I don't have enough reputation to past a comment so I'm going to place an answer.
In my understanding to derive this formula you have to go through the sum of squared residuals.
residual = E_i = (y_i - (b_o + b_1*X_i)) = (y_i - b_0 - b_1*x_i)
Therefore the sum of squared residuals =
SUM (E_i)^2 from i to n which = sum(y_i - b_0 - b_1*x_i)^2 from i to n
we know that b_0 and b_1 = 0 because they are constants and when you take the partial derivative they should also equal 0 so we can set that equation. In this case since you are only asking about b_1 we will only do that equation.
derivative of Sr/b_1 = 0
which is the same as
derivative Sr/b_1 sum(y_i - b_0 - b_1*x_i)^2 from i to n
= sum(2(y_i - b_0 - b_1*X_i)(-X_i) = 0 from i to n
= -2sum(X_iY_i) + 2sum(b_0*X_i) + 2sum(X_i^2) = 0 with all sums being from i to n
You can now divide both sides by two to remove those and move the sum(X_i*Y_i) to the other side.
You can now pull out constants from the sumation.
b_0*sum(X_i) + b_1*sum(X_i^2) = sum(X_i*Y_i)
Use algebra to solve.
b_1 = nsum(X_iY_i) - sum(X_i)sum(Y_i) / nsum(X_i^2) - (sum(X_i))^2
Which I believe is the same as your equation above.
Again I could be completely wrong, this is just how I remember it and how it was described to me.