how the earth works