Why Earth Has Layers at All