In Stein's Complex Analysis notes, the following exampleis given.
They then proceed to calculate the integral over the small semicircle.
My question is, why is it necessary to dodge the origin? Afterall, the singularity at $z=0$ is removable?
The singularity is removable for the function you want to integrate but not for their $f(z).$
The motivation for the question seems to be: Why does the author integrate $f(z)=(1-e^{iz})/z^2$ over the complex plane, rather than the original integrand $g(z)=(1-\cos z)/z^2$ ? You're right that $g$ is an entire function, and it could be integrated over a semicircle without having to dodge the origin.
However, the integral of $g$ over the arc $\gamma_R^+$ doesn't obey a nice bound. While integrating $f$, the author needs the inequality $$ \left|\frac{1-e^{iz}}{z^2}\right|\leq\frac{2}{|z|^2}, $$ which is justified by the fact that $|e^{iz}|\leq 1$ for $z$ in the upper half-plane. The same can't be said for $\cos z=(e^{iz}+e^{-iz})/2$; instead, the $e^{-iz}$ term is large in the upper half-plane. That's why $g$ is less convenient than $f$.
We can evaluate the integral using Feynman's trick:
$$ I = \int_0^\infty \frac{1 - \cos(x)}{x^2}dx = I(1) $$
$$ I(a)= \int_0^\infty \frac{1 - \cos(ax)}{x^2}dx $$
$$ \frac{dI(a)}{da}= \int_0^\infty \frac{\partial}{\partial a} \Bigg(\frac{1 - \cos(ax)}{x^2}\Bigg)dx = \int_0^\infty \frac{\sin(ax)}{x}dx = \frac{\pi}{2}$$
$$ I(a) = \frac{\pi}{2}a+C_1 $$ $$ I(0) = 0 = 0+C_1 \to C_1 = 0 $$ $$ I = I(1) = \frac{\pi}{2} $$