It is well known that the representation number of sum of three squares is related to the (form) class number of binary quadratic forms, which was proved by Gauss.
But, I could not find references to explain his motivation for this relation.
I appreciate if you teach me how Gauss recognized the relation.