$$
\int_0^\infty\frac{\cos 2\,x-1}{x^2}\,dx=\frac12\,\int_{-\infty}^\infty\frac{\cos 2\,x-1}{x^2}\,dx=\frac12\,\int_{-\infty}^\infty\frac{\Re(e^{2ix}-1)}{x^2}\,dx.
$$
The key is the choice of function to integrate along a path. The function
$$
f(z)=\frac{e^{2iz}-1}{z^2}=\frac{2\,i}{z}-2-\frac{4\,i}{3}\,z+\cdots
$$
has a simple pole at $z=0$ with residue $2\,i$. Take $R>0$ large and $\epsilon>0$ small. Integrate along a path formed by the positively oriented semicircle of radius $R$ in the upper half plane ($C_R$), the interval $[-R,-\epsilon]$ ($C_\epsilon$), the semicircle of radius $\epsilon$ negatively oriented and the interval $[\epsilon,R]$ and take the limit as $R\to\infty$ and $\epsilon\to0$. The integral along the path is zero, $\lim_{R\to\infty}\int_{C_R}f(z)\,dz=0$, but $\lim_{R\to\infty}\int_{C_\epsilon}f(z)\,dz=?$.
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
Let's factorize the denominator : $x^2+x-2=(x+2)(x-1)$
so that $\displaystyle \frac1{x^2+x-2}=\frac13\left(\frac1{x-1}-\frac1{x+2}\right)$
Let's try a direct proof without complex integration. $$P.V. \int_0^{\infty} \frac 1{x^2+x-2}=\frac13 P.V.\int_0^{\infty} \frac1{x-1}-\frac1{x+2} dx=$$ $$ =\frac13 \lim_{\epsilon\to 0}\left[\int_0^{1-\epsilon} \frac1{x-1}-\frac1{x+2} dx+\int_{1+\epsilon}^{\infty} \frac1{x-1}-\frac1{x+2} dx\right] $$
$$ =\frac13 \lim_{\epsilon\to 0}\left[ \left[\log(1-x)-\log(x+2)\right]_0^{1-\epsilon}+ \left[\log(x-1)-\log(x+2)\right]_{1+\epsilon}^{\infty}\right] $$ $$ =\frac13 \lim_{\epsilon\to 0}\left[\log(\epsilon)-\log(3-\epsilon)+\log(2)-\log(\epsilon)+\log(3+\epsilon)\right] $$ (using $\lim_{R\to \infty}\log\left(\frac{R-1}{R+2}\right)=0$) $$ =\frac{\log(2)}3 $$