The Earth takes approximately 24 hours to complete one rotation, resulting in a day-night cycle, because of its historical formation and subsequent gravitational interactions.
During the formation of the solar system about 4.6 billion years ago, a rotating disk of gas and dust gradually coalesced to form the Sun and the planets. As the material in the disk came together, it conserved the total angular momentum of the system. Angular momentum is a property related to the rotation of an object and is determined by its mass, shape, and speed of rotation.
In the case of Earth, as the planet formed, the collision and accretion of countless smaller objects contributed to its mass and rotation. Due to the conservation of angular momentum, the total angular momentum of the system remained relatively constant as these objects coalesced. As a result, Earth acquired a certain amount of angular momentum, causing it to rotate.
The rate at which Earth rotates is influenced by several factors, including its mass and shape. The distribution of mass within the planet and its flattening at the poles (due to its rotation) affect the rotational speed. Over time, Earth has reached a rotational equilibrium where the forces acting upon it, including gravitational forces from the Sun and Moon, have stabilized its rotation.
The 24-hour period that we measure as a day is referred to as a solar day, which is based on the position of the Sun in the sky. However, it's worth noting that the Earth's rotation is not precisely 24 hours long. It takes about 23 hours, 56 minutes, and 4 seconds for the Earth to complete a full rotation relative to distant stars. This is known as a sidereal day. The difference between the solar day and the sidereal day is due to the Earth's orbit around the Sun, which causes an additional four minutes for the Sun to return to the same position in the sky.
In summary, the Earth takes approximately 24 hours to complete one rotation due to the conservation of angular momentum during its formation and subsequent gravitational interactions within the solar system.