It's a theorem of analytic number theory. It's just a special value of the ζ-function. People misunderstand how analytic continuation works and therefore (wrongly) interpret ζ(-1) as the divergent series 1+2+3+... (The correct interpretation is as the unique analytic continuation of the holomorphic function $\sum_{n\geq 1}\frac{1}{n^s}$ defined on the half-plane $\Re(s)>1$ to $\mathbb{C}\setminus\{1\}$.)
It's actually a pretty simple consequence of the functional equation for ζ and a few special values of Γ. That in turn comes from a theta-function identity which can be proven using Poisson's summation formula.
What I'm trying to say is that it's legit maths, that has been distorted due to the shock value of writing the equation "1+2+3+... = -1/12".
If you're looking for a reference, go to Davenport's "Multiplicative Number Theory". It's short, self-contained, and extremely well-written. Serre's "A Course in Arithmetic" should also work.