According to science theory, cause of fusion, earth was spit by sun. At initial stage, earth was a fire ball. That fireball gradually changes into cool and it was an apt place for living things. Earth has Iron core and magnetic field. Electrical currents generates by rapid rotation of earth’s molten iron core. These electrical currents produce magnetic field.
Even though mercury is so small, it has a large iron core and a magnetic field. But its magnetic field is 100 times weaker than Earth's. Because it’s rotation is too slowly to generate a magnetic field. It is not a suitable planet for living things.
At initial explosion, Earth was spinning very fast as a molten glob. The Earth settled down in a very fortunate orbit. At 93 million miles distance from the Sun it receives the right amount of radiant energy. Cause of those actions earth became a proper place for existence of life.
Earth’s spinning has gradually slowed down over these billion of years and is settled into a 24 hour rotation. Cause of this spinning we calculated day, week, month, years. This spinning will become very slow after billion of years.