Gravity formed the early Earth into the most compact shape possible