First note that the integral may be written as
$$\frac12 \int_{-\infty}^{\infty} dx \frac{\cos{a x}}{1+x^2} - \frac12 \frac{d}{da} \int_{-\infty}^{\infty} dx \frac{\cos{a x}}{1+x^2} $$
So consider the contour integral
$$\oint_{C(a)} dz \frac{e^{i a z}}{1+z^2} $$
where $C(a)$ is a semicircle of radius $R$ in the upper half plane when $a\gt 0$ and in the lower half plane when $a \lt 0$. For example, when $a \gt 0$, the integral is
$$\int_{-R}^R dx \frac{e^{i a x}}{1+x^2} + i R \int_0^{\pi} d\phi \, e^{i \phi} \frac{e^{i a R \cos{\phi}} e^{-a R \sin{\phi}}}{1+R^2 e^{i 2 \phi}} $$
As $R \to \infty$, the magnitude of the second integral is bounded by
$$\frac{2 R}{R^2-1} \int_0^{\pi/2} d\phi \, e^{-2 a R \phi/\pi} = \frac{\pi}{a (R^2-1)} \left ( 1-e^{-a R} \right )$$
which clearly vanishes in this limit. On the other hand, the contour integral is also equal to $i 2 \pi$ times the residue at the pole $z=i$, so that
$$\int_{-\infty}^{\infty} dx \frac{\cos{a x}}{1+x^2} = i 2 \pi \frac{e^{-a}}{2 i} = \pi \, e^{-a} \quad (a\gt 0)$$
(Here we used the symmetry of the integrand to get the original integral back.) For $a \lt 0$, we close in the lower half plane (or simply use the evenness of the cosine) and find that
$$\int_{-\infty}^{\infty} dx \frac{\cos{a x}}{1+x^2} = \pi \, e^{-|a|} $$
We then take the derivative of this integral (separately for the cases $a \gt 0$ and $a \lt 0$) find that the original integral is
$$\int_0^{\infty} dx \frac{\cos{a x} + x \sin{a x}}{1+x^2} = \frac{\pi}{2} \left (1+\operatorname{sgn}{a} \right )e^{-|a|} = \pi \theta(a) e^{-|a|}$$
where $\theta$ is the Heaviside step function, which is equal to $1/2$ when $a=0$.