The Earth has two major components of motion. First, it spins on its rotational axis; a full spin rotation takes one Day to complete. Second, it orbits around the Sun; a full orbital rotation takes one Year to complete.
There are normally 365 days in one calendar year, but it turns out that a true year (i.e., a full orbit of the Earth around the Sun; also called a tropical year) is a little bit longer than 365 days. In other words, in the time it takes the Earth to complete one orbital circuit, it completes 365.24219 spin rotations. Don't be too suprised by this; there's no reason to expect the spin and orbital motions of the Earth to be synchronized in any way. However, it does make marking calendar time a bit awkward!
What would happen if we simply ignored the extra 0.24219 rotation at the end of the year, and simply defined a calendar year to always be 365.0 days long? The calendar is basically a charting of the Earth's progress around the Sun. If we ignore the extra bit at the end of each year, then with every passing year, the calendar date lags a little more behind the true position of Earth around the Sun. In a few centuries, Winter will begin in September!
In fact, it used to be that all years were defined to have 365.0 days, and the calendar “drifted” away from the true seasons as a result. In the year 46 BCE, Julius Caeser established the Julian Calendar, which implemented the world's first leap years: He decreed that every 4th year would be 366 days long, so that a year was 365.25 days long, on average. This basically solved the calendar drift problem.
However, the problem wasn't completely solved by the Julian calendar, because a tropical year isn't 365.25 days long; it's 365.24219 days long! You still have a calendar drift problem, it just takes many centuries to become noticeable. And so, in 1582, Pope Gregory XIII instituted the Gregorian calendar, which was largely the same as the Julian Calendar, with one more trick added for leap years: even Century years (those ending with the digits "00") are only leap years if they are divisible by 400. So, the years 1700, 1800, and 1900 were not leap years (though they would have been under the Julian Calendar), whereas the year 2000 was a leap year. This change makes the average length of a year 365.2425 days. So, there is still a tiny calendar drift, but it amounts to an error of only 3 days in 10,000 years! The Gregorian calendar is still used as a standard calendar throughout most of the world.
Fun Trivia: When Pope Gregory instituted the Gregorian Calendar, the Julian Calendar had been followed for over 1500 years, and so the calendar date had already drifted by over a week. Pope Gregory re-synchronized the calendar by simply eliminating 10 days! In 1582, the day after October 4th was October 15th!