Another approach is to use Parseval's Theorem. First we write
$$\frac{1-\cos x}{x^2}=\frac{2\sin^2(x/2)}{x^2}=2\left(\frac{\sin (x/2)}{x}\right)^2$$
Then, we have
$$\int_0^\infty \frac{1-\cos x}{x^2}\,dx=\int_{-\infty}^\infty\left(\frac{\sin (x/2)}{x}\right)^2\,dx$$
Recall that the Fourier Transform of $\frac{\sin (x/2)}{x}$ is $\int_{-\infty}^\infty \frac{\sin(x/2)}{x}\,e^{ikx}\,dx= \pi\text{rect}(x)$, where $\text{rect}(k)$ is the Rectangular Function. Then, Parseval's Theorem yields
$$\int_{-\infty}^\infty\left(\frac{\sin (x/2)}{x}\right)^2\,dx=\frac1{2\pi}\int_{-\infty}^\infty \left(\pi \text{rect}(k)\right)^2\,dk=\frac{\pi}2$$