The answer to your main question
When can you use the residue at $\infty$ to calculate the value of an integral $\int f$ ?
is basically given by the following result.
If $f$ is a holomorphic function in $\mathbb{C}$, except for isolated singularities at $a_1, a_2, \dots , a_n$, then $\operatorname{Res}{(f; \infty)} = -\sum_{k = 1}^{n} \operatorname{Res}{(f; a_k)} $
were the residue at infinity is defined as in the wikipedia article. Now, from Cauchy's residue theorem it follows that
$\operatorname{Res}{(f; \infty)} = -\frac{1}{2 \pi i} \int_{\gamma} f(z) \, dz $
where you can take $\gamma$ to be a circle $|z| = R$, where $R$ is large enough so that all the singularities $a_k$ are contained inside the circle. Of course you can then use the more sophisticated versions of Cauchy's integral theorem to change the curve $\gamma$, but this one suffices for simplicity.
Then the last formula gives you a way to calculate a complex integral just by calculating the residue at infinity of the function, instead of computing all the "finite" residues.
Now to answer your second question of why this is the case, maybe a sketch of a proof of this result will be enough.
So let $\displaystyle{F(z) := -z^{-2}f(z^{-1})}$, then since $f(z)$ is holomorphic for $|z| > R$ for some large enough $R$, we see that $F(z)$ is holomorphic for $|z^{-1}| > R$, or equivalently, for $0 < |z| < \frac{1}{R} $. Thus $F$ has an isolated singularity at the origin, and then by the definition of the residue at infinity we have
$ \operatorname{Res}{(f; \infty)} := \operatorname{Res}{(F; 0)} = \frac{1}{2 \pi i} \int_{|w| = \frac{1}{R}} F(w) \, dw = \frac{1}{2 \pi i} \int_{|w| = \frac{1}{R}} -\frac{f(w^{-1})}{w^2} \, dw $
Then by making the substitution $z = \frac{1}{w}$ we get
$ \frac{1}{2 \pi i} \int_{|w| = \frac{1}{R}} -\frac{f(w^{-1})}{w^2} \, dw = \mathbf{\color{red}{-}} \frac{1}{2 \pi i} \int_{|z| = R} \, f(z) dz $
where the last negative sign comes from the fact that the new circle $|z| = R$ you get after the substitution has its orientation reversed. And this last equality is precisely what we wanted to prove.
Note
This result is exercise 12 in section V.2 in Conway's book Functions of One Complex Variable I (page 122), or it also appears in exercise 6 in section 13.1 of Reinhold Remmert's book Theory of Complex Functions (page 387), in case you want some references.