My textbook writes the following proof for the statement in the title:
For a homomorphism $\varphi:G \to G'$ and any $g\in G$, $\varphi(g) = \varphi(ge) = \varphi(g)\varphi(e)$. Multiplying both sides of this equation on the left by $(\varphi(g))^{−1}$ gives the desired result, $e′ = e′\varphi(e) = \varphi(e)$.
It's not clear to me why we should be able to work like this. In particular, we only have that $\varphi(g) = \varphi(g)\varphi(e)$ for all elements in $G'$ of the form $\varphi(g)$. But it seems like the proof is tacitly using that $e'$ is the unique element for which $e'g' = g'$ for all $g \in G'$...and yet we haven't shown that $\varphi(e)$ actually does this for every $g'$!
Because every element in a group has an inverse, it's enough for
$$fg' = g'$$
for just one $g'\in G'$ to prove that $f$ is the identity.
The fact that we already know that $G'$ is a group has done most of the work for us - we know that there is an element in $G'$ that preserves every element when you multiply by it, we just have to show that that's what $\varphi$ maps $e$ to.