I am having trouble understanding the derivation presented in chapter 2 of Overview of Quantum Field Theory, in which the authors show that the a particular function, denoted as $D_R(x-y)$ is the Green's function for the Klein-Gordon equation. Here is the derivation for $D_R(x - y)$, which is equation (2.54) in the book:
$\langle0|[\phi(x), \phi(y)] |0\rangle = \int \frac{d^3p}{(2\pi)^3}\frac{1}{2E_p}\big(e^{-ip\cdot (x - y)} - e^{ip\cdot (x - y)} \big) = \int \frac{d^3p}{(2\pi)^3}\int \frac{dp^0}{2\pi i}\frac{-1}{p^2 - m^2}e^{-ip\cdot (x - y)}$
$D_R(x - y) \equiv \theta(x^0 - y^0)\langle0|[\phi(x), \phi(y)] |0\rangle$
The results of equation 2.56 (see below) are confusing me. I can derive the equations after the first equals sign (it is just the product rule); however, right after the second equals sign I see that the first term contains a $\pi(x)$. Why can we say this, because after all the derivative on the first term applies only to the step function $\theta(x^0 - y^0)$? Also after the first equal sign, I am confused again: why is the expression after the second equals sign equal to the four dimensional Dirac delta? I believe it has something to do with equation 2.54 but I am not sure how the math works; can someone explain?
$(\partial^2 + m^2)D_R(x - y) = (\partial^2 \theta(x^0 - y^0))\langle0|[\phi(x), \phi(y)] |0\rangle + 2(\partial_\mu \theta(x^0 - y^0))(\partial^{\mu}\langle0|[\phi(x), \phi(y)] |0\rangle) + \theta(x^0 - y^0)(\partial^2 + m^2)\langle0|[\phi(x), \phi(y)] |0\rangle$
$= -\delta(x^0 - y^0)\langle0|[\pi(x), \phi(y)] |0\rangle + 2\delta(x^0 - y^0)\langle0|[\pi(x), \phi(y)] |0\rangle + 0$
$= - i\delta^4(x - y)$