The alteration of day and night occurs due to the rotation of the Earth on its axis. As the Earth rotates, one half of it faces towards the Sun, while the other half faces away from it. The side facing the Sun experiences daylight, while the side facing away from it experiences darkness or night.
Here is a simple diagram to show the process:
As the Earth rotates from left to right in this diagram, the side facing towards the Sun experiences daylight, while the side facing away from it experiences darkness. This alternation of day and night continues as the Earth rotates on its axis, completing one rotation every 24 hours.