Does current flow when you connect a battery to earth? Let's say that the earth has 0V and everything is ideal,
does current still flow and why?

 A: An ideal voltage source is a two-terminal device that maintains a fixed non-zero(in case of finite circuit resistance) voltage drop across its terminals. 
In your diagram, name the positive terminal $A$, the negative terminal $B$ and the earthing point $C$.
Funny thing is, if everything in the diagram is 'ideal', then is gives a contradiction. Since both $A$ and $B$ are at the same potential as $C$(which is chosen to be zero for convenience), the emf of the voltage source is just $V_A - V_B = 0$ which makes no sense(as if there is short-circuit in place of the emf source).
However, a realistic interpretation would be to assume the voltage source to be a finite source of energy, whereby, initially(before connecting the circuit), $V_A \ne 0$ and $V_B = V_C = 0$, and after connection, only for a finite time, will current flow, through the circuit $AC$ and not $BC$. Current will flow, only as long as the chemical reactions in the battery maintain a non-zero potential $V_A$.
P.S: One may argue, w.r.t some model that the potential $V_A$ can only be asymptotically 0, and never actually reach 0 in finite time. We neglect such trivialities in interpreting the overall working of the circuit. Feel free to point out any mistakes.
A: The resistivity of the earth is about $\rho_{earth} \sim 1 k\Omega m$ (the accurate value depends on the soil).
So when connecting the battery to two electrodes separated by a distance $d$ the ground, a current flows through your circuit according to the Ohm's law:
$$ I= d\ V_{battery}/\rho_{earth}$$ 
