We know that the current in the circuit
$I=\frac{E}{R+r}$
and power delivered to the resistance $R$ is
$P=I^{2} R=\frac{E^{2} R}{(R+r)^{2}}$
It is maximum when $\frac{d P}{d R}=0$
$\frac{d P}{d R}=E^{2}\left[\frac{(r+R)^{2}-2 R(r +R)}{(r +R)^{4}}\right]=0$
or $(r+ R)^{2}=2 R(r+ R)$ or $R=r$