Here is an approach that uses the following identity for Laplace transforms
$$\int_0^\infty f(x) g(x) \, dx = \int_0^\infty \mathcal{L} \{f(x)\} (s)\mathcal{L}^{-1} \{g(x)\} (s) \, ds.$$
Recently this identity has been referred as the Maz identity for Laplace transforms.
Setting $f(x) = 1 - 3\cos 2x + 3 \cos 3x$ and $g(x) = \frac{1}{x^2}$, it is easy to see that
\begin{align*}
\mathcal{L}\{f(x)\} &= \mathcal{L}\{1 - 3\cos 2x + 2 \cos 3x\} = \mathcal{L}\{1\} - 3 \mathcal{L}\{\cos 2x \} + 2 \mathcal{L}\{\cos 3x \}\\
&= \frac{1}{s} - \frac{3s}{s^2 + 4} + \frac{2s}{s^2 + 9},
\end{align*}
and
$$\mathcal{L}^{-1} \{g(x)\} = \mathcal{L}^{-1} \left \{\frac{1}{x^2} \right \} = s.$$
So from the Maz identity one has
\begin{align*}
\int_0^\infty \frac{1 - 3\cos 2x + 2 \cos 3x}{x^2} \, dx &= \int_0^\infty \left [\frac{1}{s} - \frac{3s}{s^2 + 4} + \frac{2s}{s^2 + 9} \right ] s \, ds\\
&= \int_0^\infty \left [1 - 3 \frac{s^2}{s^2 + 4} + 2 \frac{s^2}{s^2 + 9} \right ] \, ds\\
&= \int_0^\infty \left [1 - 3 \frac{(s^2 + 4) - 4}{s^2 + 4} + 2 \frac{(s^2 + 9) - 9}{s^2 + 9} \right ] \, ds\\
&= \int_0^\infty \left [1 - 3 + \frac{12}{s^2 + 4} + 2 - \frac{18}{s^2 + 9} \right ] \, ds\\
&= 12 \int_0^\infty \frac{ds}{s^2 + 4} - 18 \int_0^\infty \frac{ds}{s^2 + 9}\\
&= 6 \arctan \left (\frac{s}{2} \right ) \Big{|}_0^\infty - 6 \arctan \left (\frac{s}{3} \right ) \Big{|}_0^\infty\\
&= 6 \cdot \frac{\pi}{2} - 6 \cdot \frac{\pi}{2} = 0,
\end{align*}
as required to show.