Let $f(z)=\frac{1}{z^2+1}$ and the contour $C$ be the closed half circle of radius R as described above. Let $C_R$ be the arc of the half circle $C$ with radius $R$. Using residue theorem, we have
$\oint_{C}f(z) dz=\int_{-\infty}^{\infty}f(x)dx+\int_{C_R}f(z) dz=2\pi i\sum\text{Residues} \Rightarrow \int_{-\infty}^{\infty}f(x)dx = 2\pi i\sum\text{Residues}-\int_{C_R}f(z) dz$
We start by proving
$\lim_{R \to \infty}\int_{C_R}f(z) dz=0$
We let M be the maximum value of the function on the contour, and L be the length of the contour. $\left|\int_{C_R}\frac{dz}{z^2+1}\right| \leq ML$
By inspection, $L = \pi R$. We proceed to find M:
$M=\left|\frac{1}{z^2+1}\right|=\frac{1}{|z^2+1|}=\frac{1}{|z|^2+1}=\frac{1}{R^2+1}$
Thus
$\lim_{R \to \infty}\left|\int_{C_R}\frac{dz}{z^2+1}\right| \leq \lim_{R \to \infty} ML=\lim_{R \to \infty} \frac{\pi R}{R^2+1}=0$
So this integral becomes zero. Now we have
$\int_{-\infty}^{\infty}\frac{dx}{x^2+1} = 2\pi i\sum\text{Residues}$
so we must find the required residues. To compute the residues, we expand $f(z)$ and find that there are singularities when $z= \pm i$
$f(z)=\frac{1}{(z+i)(z-i)}$
The singularity $z=i$ is the only one within the contour $C$, so this is the only residue we need to compute. To compute this residue (let it be called $b$), we do the following:
$b=\lim_{z \to i} (z-i)f(z) =\lim_{z \to i} \frac{(z-i)}{(z+i)(z-i)}=\frac{1}{(i+i)}=\frac{1}{2i}$
This is the only residue that needs to be computed, thus we can find the value of the integral:
$\int_{-\infty}^{\infty}\frac{dx}{x^2+1} = 2\pi i b = \frac{2 \pi i}{2 i}=\pi$
So the integral is found to equal $\pi$.