Consider integrating the function
$$f(z) = \frac{e^{iz}}{(z^2+1)^2}$$
along the contour $C_R$, the curve from -R to R along the real line and then along the half circle in the upper half plane from R to R (semicircle lying on real line).
For $R>1$ , by the residue theorem and $f$ being holomorphic in $\{Im(z)>0\} \setminus \{i\}$ we have
$$\oint_{C_R}f(z) dz = 2\pi i \text{Res}_f(i)$$
Now $f$ has a pole of order 2 at $i$ so
$$\text{Res}_f(i) = \left. \frac{d}{dz}\left(\frac{e^{iz}}{(z+i)^2}\right)\right|_{z=i} = -\frac{i}{2e}$$
then let $R \rightarrow \infty$ and use Jordan's lemma to get that the integral around the half circle arc of radius R tends to 0. So
$$\int_{-\infty}^{\infty}f(t) dt = \frac{\pi}{e}$$
Hence by taking the real part
$$\int_{-\infty}^{\infty}\frac{\cos(x)}{(x^2+1)^2} dx = \frac{\pi}{e}$$
Consider integrating the function $$f(z) = \frac{e^{iz}}{(z^2+1)^2}$$ along the contour $C_R$, the curve from -R to R along the real line and then along the half circle in the upper half plane from R to R (semicircle lying on real line).
For $R>1$ , by the residue theorem and $f$ being holomorphic in $\{Im(z)>0\} \setminus \{i\}$ we have $$\oint_{C_R}f(z) dz = 2\pi i \text{Res}_f(i)$$ Now $f$ has a pole of order 2 at $i$ so $$\text{Res}_f(i) = \left. \frac{d}{dz}\left(\frac{e^{iz}}{(z+i)^2}\right)\right|_{z=i} = -\frac{i}{2e}$$ then let $R \rightarrow \infty$ and use Jordan's lemma to get that the integral around the half circle arc of radius R tends to 0. So $$\int_{-\infty}^{\infty}f(t) dt = \frac{\pi}{e}$$ Hence by taking the real part $$\int_{-\infty}^{\infty}\frac{\cos(x)}{(x^2+1)^2} dx = \frac{\pi}{e}$$