Here are two common ways of obtaining that result.
1) Analytic continuation of the zeta function. For $\operatorname{Re} s>1$, the Riemann zeta function is defined by $$\zeta(s)=\sum_{n=1}^\infty n^{-s}$$
This function satisfies the Riemann functional equation
$$\zeta(s)=2^s\pi^{s-1}\sin\left(\frac{\pi s}{2}\right)\Gamma(1-s)\zeta(1-s)$$
which is valid on the whole complex plane. (Here $\Gamma(z)$ is the gamma function.) Now, your sum is evidently $\zeta(-1)$, which can't be calculated directly using the sum definition, but using this analytic continuation one finds $\zeta(-1)=-1/12$. This is not really saying that that sum converges to $-1/12$, but rather that the analytic continuation of a similar sum is $-1/12$.
2) Physically motivated. Physically, the $n$ here means that we have modes of the quantum field with wave number $n$. The energy of each mode is given by $\omega_n =n\pi/d$, where $d$ is the separation of the plates. These physical plates won't be able to contain waves with arbitrary energy, those will leak out and no longer contribute to the energy between the plates. So, we introduce a factor $\mathrm{e}^{-a\omega_n/\pi}$ with $a$ chosen so that modes with $\omega_n\gg\pi/a$ do not contribute to the sum. So now we have (we call the sum $\zeta(-1)$ for convenience)
$$\zeta(-1)=\sum_{n=1}^\infty n\to\sum_{n=1}^\infty n\mathrm{e}^{-an/d}=-d\frac{\partial}{\partial a}\sum_{n=1}^\infty \mathrm{e}^{-an/d}=-d\frac{\partial}{\partial a}\frac{1}{1-\mathrm{e}^{-a/d}}=\frac{d\mathrm{e}^{a/d}}{(e^{a/d}-1)^2}$$
Now we take $a$ to be small and expand
$$\zeta(-1)\to\frac{d^2}{a^2}-\frac{1}{12}+\mathcal{O}(a^2)$$
Up to an overall factor the force between the plates is given by something like $\mathrm{d}\zeta(-1)/\mathrm{d}d$. The Taylor series diverges (it has to, we started with a divergent series), but we do not observe this in nature. (There is a force between the plates, but it surely isn't infinite.) Now, it turns out that when you do the same calculation for for the other plate, the infinite terms cancel exactly. And in the limit of $a\to0$, all the terms with $a$ vanish. So, physically, it was as if we had taken $\zeta(-1)=-1/12$ all along.