The Earth is constantly spinning on its axis, allowing sunlight to shine on different areas of the Earth at different times of the day, creating daytime when the Sun hits a specific area. When the Sun is not shining on a specific area of the Earth, it is nighttime. Since the Sun does not hit all of the Earth at the same time, it is daytime in some parts of the world, while it is nighttime in others.
This phenomenon also explains the seasons. The part of the Earth tilted toward the Sun experiences summer. Winter occurs in the part of the Earth that is tilted away from the Sun.