We have day and night because Earth rotates on its axis.
At any moment, roughly half of Earth faces the Sun and receives sunlight. The other half faces away and is in darkness.
As the planet turns, your location moves from the dark side into sunlight and then back into darkness.
One spin produces the basic daily cycle.
Earth rotates from west to east
Earth turns eastward.
Because we are riding on the rotating planet, the Sun appears to move in the opposite direction across the sky, rising in the east and setting in the west.
The Sun is not actually circling Earth once every day.
The apparent motion mostly comes from us rotating underneath it.
One day is about one rotation
Relative to the Sun, Earth’s rotation gives us a solar day of about 24 hours.
Relative to distant stars, Earth completes a rotation in slightly less time, about 23 hours and 56 minutes.
The difference exists because Earth is also moving along its orbit around the Sun. It has to rotate a little farther each day before the Sun returns to the same apparent position in the sky.
For ordinary life and clocks, 24 hours is the useful number.
Why is it daytime in one country and nighttime in another?
Because Earth is round.
While one side faces the Sun, places on the opposite side face away.
When it is noon in one region, another region may be near midnight.
Time zones are our human system for organizing that rotating geometry into clocks.
The planet does not know what time zone it is in.
It just keeps turning.
Why are days longer in summer?
Earth’s axial tilt affects how long a particular location spends in sunlight during different parts of the year.
When your hemisphere tilts toward the Sun, your path through the sunlit half of Earth is longer. That produces longer days.
When your hemisphere tilts away, the daylight portion is shorter.
So rotation creates day and night, while Earth’s tilt changes how long each lasts through the seasons.
What is the line between day and night called?
The boundary between the illuminated and dark halves of a planet is called the terminator.
From space, it appears as a broad dividing region rather than a razor-thin line because Earth’s atmosphere scatters sunlight and creates twilight.
As Earth rotates, locations cross that boundary at sunrise and sunset.
If Earth is spinning so fast, why do we not feel it?
At the equator, Earth’s surface moves at roughly 1,000 miles per hour due to rotation.
You do not feel steady motion very well when you, the ground, the atmosphere, and almost everything around you are moving together.
You mainly feel changes in motion, such as acceleration, braking, or turning sharply.
Earth’s rotation is smooth enough that daily life does not feel like a carnival ride.
Thankfully.
So sunrise and sunset are not the Sun switching on and off.
They are what it looks like from a planet that refuses to stop spinning.
A related part of the natural world appears in Why Does Earth Have Seasons?, where the same kind of physical or biological reasoning answers another familiar question.
And that’s the short explanation.
Related explanations: Why Does Earth Have Seasons? and Why Does the Moon Have Phases?