Groups related to sum of squares function? I will begin by saying that $k=3$ might be a very specific case and this question is useless. Even if that is the case, I would like to know...
The sum of squares function $r_k(n)$ is very famous. It counts the number of ways $n$ can be written as a sum of $k$ squares. In the case of $k=3$, when $n$ is squarefree and not $7\mod{8}$, $r_k(n)$ is related to the class number of $\mathbb{Q}(\sqrt{-n})$. In the next (at least) two odd cases the function is still related to arithmetic constants of quadratic fields. C.f. "On the Representation of a Number as the Sum of any Number of Squares, and in Particular of five or seven", Hardy, 1918.
Question
Are the numbers $r_k(n)$ known to be related to special groups, like when $k=3$?
Smaller Question
Is there a book with an in-depth account of these numbers and their arithmetic significance? (more than expressing them as coefficients of a modular form and proving bounds and (lots of) relations...)
 A: In my view, it depends a little what you mean by "related," but I don't see at first glance any natural group whose order is r_k(n) for any k other than 3.  Loosely speaking, representations of a form of rank m by the genus of a form of rank n are related to the set of double cosets
H(Q) \ H(A_f) / H(Zhat)
where H is a form of SO_{n-m} (this can be found e.g. in my paper with Venkatesh "Local-global principles..." but is certainly known to others).  When H is abelian (i.e. when n-m = 2) this is naturally a group, otherwise not.  
A: Steve Milne sent me a copy, and a pdf, of his "Infinite Families of Exact Sums of Squares Formulas, Jacobi Elliptic Functions, Continued Fractions, and Schur Functions" which is an entire issue of The Ramanujan Journal: vol. 6, no. 1, March 2002. There is also a two-page preface by George Andrews. I admit, the main focus is dimension $4 n^2$ or $ 4 ( n^2 + n).$ But at 143 pages and 259 references, there might be something you like. Email me if you would like  the pdf, it is not obvious to me that there was implied permission for me  to post it on any websites. 
A: For  general odd $k=2m+1$ one can still compute the value of the singular series as Hardy does and obtain a formula similar to those for $k=5,7$, involving the value of an $L$-series with quadratic character at $s=m$. A relation to special groups as in the case $k=3$ is not visible from this, just a relation to the arithmetic of quadratic number fields.
For $k \ge 9$, however, the genus of the sum of $k$ squares contains more than one integral equivalence class and by Siegel's Massformel (mass formula) evaluation of the singular series gives the average of the representation numbers for the equivalence classes in the genus and not the representation number of the individual form. (The genus of an integral quadratic form $q$ consists of those forms which have the same signature and are integrally equivalent modulo $m$ for all integral $m$.)  Of course this doesn't exclude the possibility of finding a closed formula by other means, as was the case for the special dimensions of the form  $4m^2$ or $4(m^2+m)$ in the work of Milne mentioned in Jagy's answer. To my knowledge at present no such formula is known for an odd number $k$ of variables.
Concerning references: The standard reference for sums of squares is still Grosswald's book. Good references for more general questions concerning the arithmetic of quadratic forms are the books of B. Jones, Y. Kitaoka, O. T. O'Meara, G. Shimura  and (in german) of M. Eichler and of M. Kneser.
