I think it's easiest to work it out backwards, start with step 3 and show it equals step 2. Before I do that though I want to comment on the appearance of the $p^0$ integral. The integral over $d^3p$ is a little misleading, as the integral is not performed over all of momentum, but is instead restricted to "on-shell" momentum (the positive invariant mass shell hyperboloid in 4-momentum space). This integral would look like,
\begin{equation}
\int \frac{d^3\textbf{p}}{(2\pi)^3} \frac{dp^0}{2\pi} (2\pi) \delta^{(4)}\big((p^0)^2 - |\textbf{p}|^2 - m^2\big)f(p)\bigg|_{p^0 > 0} = \int \frac{d^3\textbf{p}}{(2\pi)^3}\frac{1}{2(p^0)^2}f(p)\bigg|_{p^0 = |\textbf{p}|^2 + m^2}
\end{equation}
This is given in Peskin & Schroeder eq. 2.40, and uses eq. 2.34 for evaluating the delta function. So there is an inherent integral/restriction in momentum space. I suspect you could use this to massage step 2 to step 3, but I found it easier to start with step 3 and get to step 2.
Now taking equation 3, split the denominator into 2 parts and the poles become clear,
\begin{equation}
\int\frac{d^3\textbf{p}}{(2\pi)^3}e^{i\textbf{p}\cdot(\textbf{x}-\textbf{y})}\int \frac{dp^0}{2\pi i}\frac{-1}{\big(p^0 + \sqrt{|\textbf{p}|^2 +m^2}\big)\big(p^0 - \sqrt{|\textbf{p}|^2 +m^2}\big)}e^{-ip^0(x^0-y^0)}
\end{equation}
Now if we hold $\textbf{p}$ fixed and consider the integral over $p^0$ we have 2 poles, one at $p^0 = \sqrt{|\textbf{p}|^2 +m^2}=E_\textbf{p}$, and the other at $p^0 = -\sqrt{|\textbf{p}|^2 +m^2}=-E_\textbf{p}$. If $x^0 > y^0$ then the exponential argument $e^{-ip^0(x^0-y^0)}$ goes to zero for $\text{Im}(p_0) < 0$, so we close our contour below and include both poles in our contour (we pick up a minus sign from the direction of our contour integration).
Using the residue theorem, $\oint f(z) = 2\pi i \sum \text{Res}(f(z))$ we can do the $p_0$ integral,
\begin{align}
\int \frac{dp^0}{2\pi i}\frac{-1}{\big(p^0 + E_\textbf{p}\big)\big(p^0 - E_\textbf{p}\big)}e^{-ip^0(x^0-y^0)}&= \frac{1}{2\pi i} 2\pi i\bigg(\frac{1}{2E_\textbf{p}}e^{-iE_\textbf{p}(x^0-y^0)}+\frac{1}{-2E_\textbf{p}}e^{iE_\textbf{p}(x^0-y^0)}\bigg)
\end{align}
Combining this with the momentum integral and exponential,
\begin{align}
\int d^3\textbf{p}&e^{i\textbf{p}\cdot(\textbf{x}-\textbf{y})}
\bigg(\frac{1}{2E_\textbf{p}}e^{-iE_\textbf{p}(x^0-y^0)}-\frac{1}{2E_\textbf{p}}e^{iE_\textbf{p}(x^0-y^0)} \bigg)\\
&=\int \frac{d^3\textbf{p}}{(2\pi)^3}\bigg(\frac{1}{2E_\textbf{p}}e^{-iE_\textbf{p}(x^0-y^0)}e^{i\textbf{p}\cdot(\textbf{x}-\textbf{y})}-\frac{1}{2E_\textbf{p}}e^{iE_\textbf{p}(x^0-y^0)}e^{i\textbf{p}\cdot(\textbf{x}-\textbf{y})} \bigg)\\
&=\int \frac{d^3\textbf{p}}{(2\pi)^3}
\bigg(\frac{1}{2E_\textbf{p}}e^{-ip^0(x^0-y^0)+i\textbf{p}\cdot(\textbf{x}-\textbf{y})}\bigg|_{p^0=+E_\textbf{p}}-\frac{1}{2E_\textbf{p}}e^{-ip^0(x^0-y^0)+i\textbf{p}\cdot(\textbf{x}-\textbf{y})}\bigg|_{p^0=-E_{\textbf{p}}} \bigg)\\
\end{align}
And this is equivalent to step 2. However if $x^0 < y^0$ then you must close the contour in the positive hemisphere, now it contains no poles and is equal to zero. I think this is what they are trying to show before introducing the more common Feynman Propagator. This point is made here Klein-Gordon propagator integral