Identities like these are often used to perform calculations with Greens functions. In particular, given a Hamiltonian H, its resolvent
\((ω-H)^{-1} = \sum_n \frac1{ω-E_n} |ψ_n\rangle\langleψ_n|\)
is an object of key interest. It's essentially the Fourier transform of the corresponding Greens function.
Now, the thing about the resolvent is that is analytic for all complex values ω that are not in the spectrum of the Hamiltonian H. Hence, we can apply identities from complex analysis to perform computations.
One of the key observation of complex analysis is that complex analytic functions are very rigid: knowing the values of a function \(f\)on a countable set of points with a limit point is enough to reconstruct the whole function \(f\). The most prominent example is Cauchy's integral formula, which states that if a function is complex analytic on and inside a disk, then the values inside can be reconstructed entirely from the values on the boundary, via the following integral formula:
\(f(ω) = \frac1{2πi} \oint_{\text{circle}} dz\frac{f(z)}{z-ω}\)
The identities you mention in your question are used for the same purpose, except that in this case, we want to reconstruct a function not from its values on a circle, but from its values on the real axis.
Formula 1 is to be understood in the sense of distributions: multiply with a test function \(g\)and integrate over the whole real axis. Then, the results are equal:
\(\int^∞_{-∞} dx \frac{g(x)}{x-x_0+iε} = \mathcal{P} \int_{-∞}^∞dx \frac{g(x)}{x-x_0}- iπg(x_0)\)
(We assume that g is any continuous, complex-valued test function that decays sufficiently fast at infinity.)
Formula 2 is actually formula 1 after you perform the differentiation on the left-hand side.
Formula 3 can be derived from formula 1 for the special case where the function g is related to the values of a function f which is complex analytic in the upper and lower half plane. It is similar Cauchy's integral formula in the sense that you reconstruct the values of f in the complex plane from just the imaginary part of its values on the real axis.
My favorite example for these kinds of calculations is the function \(f(z) = \sqrt{z}\). It is complex analytic everywhere, except for the negative real numbers, where this function has a branch cut. Plug this into the formula and try to calculate the result, doing so will hopefully help you understand what is going on. (Note that the branch cut is from -∞ to 0 here, i.e. mirrored compared to formula 3.)