The Earth has leap years every four years to keep our calendar year synced up with the Earth’s position in its orbit around the sun. Our calendar year is based on the length of time it takes the Earth to make one complete orbit around the sun, which is approximately 365.25 days.
To account for this extra quarter-day in the Earth’s orbit, we add an extra day (29 February) to the calendar year every four years. This is called a leap year. However, this doesn’t mean that we have a leap year every four years precisely. To account for the imprecision caused by the 365.25 days figure, there are some additional rules that apply.
The leap year occurs only during years that are divisible by four, except for years that are divisible by 100 but not by 400. For example, the year 2000 was a leap year because it is divisible by 400, while the year 1900 was not a leap year because it’s divisible by 100 but not by 400. This ensures that we keep the calendar year reasonably synchronized with the Earth's movement, which can help with keeping time and making accurate astronomical calculations.
So, leap years and 29 February are a way to adjust the calendar year to align with the actual length of a year as determined by the Earth's orbit around the sun.