Integrals of the form
$$\int_{-\infty}^\infty \frac{p(x)}{\cosh x}\,dx,$$
where $p$ is a polynomial can be evaluated by shifting the contour of integration to a line $\operatorname{Im} z \equiv c$. We first check that the integrals over the vertical segments connecting the two lines tend to $0$ as the real part tends to $\pm\infty$:
$$\lvert \cosh (x+iy)\rvert^2 = \lvert \cosh x\cos y + i \sinh x\sin y\rvert^2 = \sinh^2 x + \cos^2 y,$$
so the integrand decays exponentially and
$$\left\lvert \int_{R}^{R + ic} \frac{p(z)}{\cosh z}\,dz\right\rvert
\leqslant \frac{K\,c}{\sinh R}\left(R^2+c^2\right)^{\deg p/2} \xrightarrow{R\to \pm\infty} 0.$$
Since $\cosh \left(z+\pi i\right) = -\cosh z$, and the only singularity of the integrand between $\mathbb{R}$ and $\mathbb{R}+\pi i$ is a simple pole at $\frac{\pi i}{2}$ (unless $p$ has a zero there, but then we can regard it as a simple pole with residue $0$) with the residue
$$\operatorname{Res}\left(\frac{p(z)}{\cosh z};\, \frac{\pi i}{2}\right) = \frac{p\left(\frac{\pi i}{2}\right)}{\cosh' \frac{\pi i}{2}} = \frac{p\left(\frac{\pi i}{2}\right)}{\sinh \frac{\pi i}{2}} = \frac{p\left(\frac{\pi i}{2}\right)}{i},$$
the residue theorem yields
$$\begin{align}
\int_{-\infty}^\infty \frac{p(x)}{\cosh x}\,dx
&= 2\pi\, p\left(\frac{\pi i}{2}\right) + \int_{\pi i-\infty}^{\pi i+\infty} \frac{p(z)}{\cosh z}\,dz\\
&= 2\pi\, p\left(\frac{\pi i}{2}\right) - \int_{-\infty}^\infty \frac{p(x+\pi i)}{\cosh x}\,dx\\
&= 2\pi\, p\left(\frac{\pi i}{2}\right) - \sum_{k=0}^{\deg p} \frac{(\pi i)^k}{k!}\int_{-\infty}^\infty \frac{p^{(k)}(x)}{\cosh x}\,dx.\tag{1}
\end{align}$$
Since $\cosh$ is even, only even powers of $x$ contribute to the integrals, hence we can from the beginning assume that $p$ is an even polynomial, and need only consider the derivatives of even order.
For a constant polynomial, $(1)$ yields
$$\int_{-\infty}^\infty \frac{dx}{\cosh x} = 2\pi - \int_{-\infty}^\infty \frac{dx}{\cosh x}\Rightarrow \int_{-\infty}^\infty \frac{dx}{\cosh x} = \pi.$$
For $p(z) = z^2$, we obtain
$$\begin{align}
\int_{-\infty}^\infty \frac{x^2}{\cosh x}\,dx &= 2\pi \left(\frac{\pi i}{2}\right)^2 - \int_{-\infty}^\infty \frac{x^2}{\cosh x}\,dx - (\pi i)^2\int_{-\infty}^\infty \frac{dx}{\cosh x}\\
&= - \frac{\pi^3}{2} - \int_{-\infty}^\infty \frac{x^2}{\cosh x}\,dx + \pi^3,
\end{align}$$
which becomes
$$\int_{-\infty}^\infty \frac{x^2}{\cosh x}\,dx = \frac{\pi^3}{4}.$$
Best Answer
$$ \begin{align} \int_{-\infty}^\infty\frac{\cos^3(x)}{x^2+1}\,\mathrm{d}x &=\frac18\int_{-\infty}^\infty\frac{e^{3ix}+3e^{ix}+3e^{-ix}+e^{-3ix}}{x^2+1}\,\mathrm{d}x\tag{1a}\\ &=\frac18\int_{H_+}\frac{e^{3iz}+3e^{iz}}{z^2+1}\,\mathrm{d}z+\frac18\int_{H_-}\frac{3e^{-iz}+e^{-3iz}}{z^2+1}\,\mathrm{d}z\tag{1b}\\ &=\frac{2\pi i}8\left(\frac{e^{-3}+3e^{-1}}{2i}\right)-\frac{2\pi i}8\left(\frac{3e^{-1}+e^{-3}}{-2i}\right)\tag{1c}\\ &=\frac\pi4\,\frac{3e^2+1}{e^3}\tag{1d} \end{align} $$ Explanation:
$\text{(1a):}$ $\cos(x)=\frac{e^{ix}+e^{-ix}}2$
$\text{(1b):}$ $H_+=[-R,R]\cup Re^{+\pi i[0,1]}$ (counterclockwise around the upper half-plane)
$\phantom{\text{(1b):}}$ $H_-=[-R,R]\cup Re^{-\pi i[0,1]}$ (clockwise around the lower half-plane)
$\phantom{\text{(1b):}}$ the integrals along the circular arcs vanish as $R\to\infty$
$\text{(1c):}$ account for the residues and directions of the contours around $i$ and $-i$
$\text{(1d):}$ simplify