Here is an example from Priestley's Complex Analysis textbook ($\Gamma_R$ is arc of semi-circle sitting on real axis centered at 0):
She is stating that to evaluate the given integral, we must equate real and imaginary parts in the following equation:
$$ \int_{-R}^R f(x) dx + \int_{\Gamma_R} f(z) dz = 2\pi i\ \mathrm{res}(f(z); \omega)$$
However, the LHS of the equation is equal to the RHS, and as $R \to \infty$, the second integral in the LHS goes to 0. The remaining integral on the LHS is real – so shouldn't the RHS automatically be real? Why is there a need to explicitly take the real part? Where have I gone wrong?

You need to take the real part because $\mathrm{Re}[f(x)]$, not $f(x)$, is the function you want to integrate. Remember that $f(x)$ was $\frac{e^{ix}}{x^2 + x + 1}.$