This follows directly from the binary nature of $Z$ and the use of the law of iterated expectations. Consider an arbitrary $W$. Then
$$Cov(W,Z) = E[W(Z-E[Z])] = E[W(1-E[Z])|Z=1]E[Z] - E[WE[Z]|Z=0](1-E[Z])$$
where we use the fact that for binary $Z$, $E[Z] = P(Z=1),$ and so $P(Z=0) = 1-P(Z=1) = 1-E[Z]$. Then it suffices to use linearity of conditional expectations to observe that
$$ E[W(1-E[Z])|Z=1]E[Z] = E[W|Z=1]E[Z](1-E[Z])$$
and
$$ E[WE[Z]|Z=0](1-E[Z]) = E[W|Z=0]E[Z](1-E[Z])$$
so the last expression in the first equation simplifies to
$$E[W(1-E[Z])|Z=1]E[Z] - E[WE[Z]|Z=0](1-E[Z]) = \bigg(E[W|Z=1]-E[W|Z=0]\bigg)E[Z](1-E[Z])$$
since this holds for any $W$, take $W=Y$ and $W=D$ and take the ratio. Then
$$\frac{Cov(Y,Z)}{Cov(D,Z)} = \frac{\bigg(E[Y|Z=1]-E[Y|Z=0]\bigg)E[Z](1-E[Z])}{\bigg(E[D|Z=1]-E[D|Z=0]\bigg)E[Z](1-E[Z])} = \frac{E[Y|Z=1]-E[Y|Z=0]}{E[D|Z=1]-E[D|Z=0]}$$
as required.