Many representations as a sum of three squares

The formula for $r_3(n)$ essentially connects this with a class number of an imaginary quadratic field, or (apart from the $\sqrt{n}$ scaling) with the value of an $L$-function at $1$. So your question may be reformulated as asking how large can $L(1,\chi_{d})$ be as $d$ runs over negative fundamental discriminants ($d$ is essentially $-n$). The distribution of these values has been extensively investigated (see for example Granville and Soundararajan where you'll find more references. To create large values of $L(1,\chi_d)$ you should find a $d$ with $\chi_d(p)=1$ for all small primes $p$ up to some point $y$. One can do this with $d$ of size about $\exp(y)$. Then for most such $d$ one will have $$ L(1,\chi_d) \approx \prod_{p\le y} \Big(1-\frac{\chi_d(p)}{p} \Big)^{-1} \asymp \log \log |d| $$ by Mertens. Arguments of this type go back to Littlewood and Chowla (see the linked paper for references).


Let me restrict to the number of primitive representations $$r_3^\ast(n) = \left|\{(a,b,c)\in {\mathbb Z}^3 :\, a^2+b^2+c^2=n\ \text{and}\ \gcd(a,b,c)=1 \}\right|.$$ Note that $r_3(n)$ can be easily expressed from this quantity as $$r_3(n)=\sum_{d^2\mid n}r_3^\ast(n/d^2).$$ Clearly $r_3^*(n)=0$ when $n\equiv 0,4,7\pmod{8}$. For the remaining cases, it follows from the work of Gauss (1801) and Dirichlet (1839) on the class number that $$r_3^\ast(n) = \frac{24}{\pi}\,\sqrt{n}\,L\left(1,\left(\frac{D}{\cdot}\right)\right),$$ where $$D=\begin{cases} -4n,&n\equiv 1,2,5,6\pmod{8},\\ -n,&n\equiv 3\pmod{8}. \end{cases}$$ This tells us that the maximal (resp. minimal) order of $r_3^*(n)$ is determined by the maximal (resp. minimal) order of $L\left(1,\left(\frac{D}{\cdot}\right)\right)$, where $D$ depends on $n$ as above. Concerning the latter quantity, Littlewood (On the class-number of the corpus $P(\sqrt{-k})$, Proc. Lond. Math. Soc. (2) 27 (1928), 358-372) proved under GRH that $$ (\log\log|D|)^{-1}\ll L\left(1,\left(\frac{D}{\cdot}\right)\right)\ll \log\log|D|,$$ and he also proved in the same article that $L\left(1,\left(\frac{D}{\cdot}\right)\right)\gg\log\log|D|$ holds for infinitely many $D$'s. This last bound was proved unconditionally by Walfisz (On the class-number of binary quadratic forms, Trav. Inst. Math. Tbilissi 11 (1942), 57-71), and was further explicated by Granville-Soundararajan (The distribution of values of $L(1,\chi_d)$, Geom. Funct. Anal. 13 (2003), 992-1028). In particular, see Theorem 5b on page 998 in Granville-Soundararajan's paper, which is also available as an arXiv preprint.

In short, there are infinitely many $n$'s such that $r_3(n)\gg\sqrt{n}\log\log n$, and this is sharp under GRH.