Why Spearman's rank correlation ranges from from -1 to 1 $$\rho = 1 - \frac{6 \sum d_i^2}{n(n^2 - 1)}$$
$\rho$ = Spearman's rank correlation coefficient
$d_i$ = difference between the two ranks of each observation
$n$ = number of observations
Given the Spearman's rank correlation above, it's clear to see the maximum is 1 as the smallest $d_i$ will be zero. I am trying to figure out why it is -1 by having two ranks in exactly reversed order.
I attach my calculation below, where the red rectangle represents the specific case of four rows, and I ordered two ranks in exactly reverse order.
The purple rectangle is the actual calculation, and it indeed results in -1.
I try to generalize in the green rectangle, but how does that formula result in 2?

 A: See Wikipedia for the definition. Note that Spearman correlation is just the usual Pearson correlation, but calculated using the ranks of the data, not the data itself.
So the reason it is always in the interval $[-1,1]$ is by the same proof as for the Pearson correlation. By using the Cauchy-Schwartz inequality.
A: As you note the sum includes $1^2+3^2+5^2+\cdots+(m-1)^2$ or $\sum_1^{m/2} (2r-1)^2$. For simplicity I'll look at the case when there are an even number of rows, ie when $m$ is even.
You can expand the sum by expanding bracket as $$\sum_1^{m/2} (2r-1)^2 = 4\sum r^2-4\sum r +\sum 1$$ and use standard formulae for the sums: $\sum_1^n r^2 = \frac16 n(n+1)(2n+1)$ and $\sum_1^n r =\frac12 n(n+1)$
This gives $$\frac46 (m/2)((m/2)+1)(m+1) - \frac42 m/2(m/2+1) + m/2= \frac16 (m^3-m).$$
We can now substitute this into your expression:
$$\frac{6\cdot(2\sum_1^{m/2} (2r-1)^2)}{m^3-m}$$
$$=\frac{6\cdot(2\cdot \frac16 (m^3-m)}{m^3-m}$$
$$=\frac{2 (m^3 -m)}{m^3-m}$$
$$=2$$
And so the Spearman rank coefficient is -1
So in this case, one can directly calculate the value.  The standard formulae may not be familiar to you. Typically they are proved by induction, but a visual proof is offered on maths StackExchange: https://math.stackexchange.com/questions/122546/gaussian-proof-for-the-sum-of-squares
