In 45 B.C., Julius Caesar was attempting to develop a 365-day calendar when he confronted a slight dilemma: The earth's orbit around the sun takes about 365 days and six hours, which would make the calendar year slightly shorter than the solar year. Not taking this into account would throw off the passage of time and changing seasons.
To remedy this, Caesar recruited an Alexandrian astronomer named Sosigenes, and together they decided to add an extra day to the calendar every four years. Though the idea seemed simple at first, after a few centuries, it was clear something was off.
Their calculations were slightly wrong. The solar year was actually a bit shorter than they had thought. So rather than catching up, the calendar was speeding ahead.
By the end of the 16th century, the calendar year had sped as much as 10 days ahead.
The introduction of the Gregorian calendar in 1582 marked the Western calendar as we now know it. The current calculation of a solar year is 365.2425 days, and though our leap year situation is still not perfect, it will be off by about one day only every 3,030 years.