I know the solution to be $\frac{\pi}{2e}$.
Here is my attempt:
Let $f(z)=\frac{e^{-iz}}{(z^2+1)^2}$ on the classic upper semicircle contour ( note that the integrand is even). $f$ has a double pole at $z=i$ inside this contour with residue $0$. It is clear that $f$ vanishes on the semi-circle as we take the radius to infinity. Hence by the residue theorem I should get, upon taking real parts, $\int^ {\infty}_{-\infty}\frac{\cos (x)}{(x^2+1)^2}=0 \neq \frac{\pi}{2e}$. What's wrong with my argument? Many thanks.
Note that $\cos(z)=\operatorname{Re}(e^{iz})$. So, it is natural to consider the integral of $\frac{e^{iz}}{(z^2+1)^2}$, whose residue at $i$ is $-\frac i{2e}$. Therefore$$\int_{-\infty}^\infty\frac{\cos x}{(x^2+1)^2}\,\mathrm dx=\frac\pi e.$$