The history of clocks and calendars is that of a constant struggle to measure time with more precision. Time and time again (so to speak), we arrive at a more accurate way to measure time, one more exact than the previous way. And over time (again please excuse the recursion) that time measurement system eventually shows some fatal weakness, exposed by either greater cultural or scientific demands of precision, or because of some inherent flaw that can no longer be ignored.
At first glance, the basics of time keeping on planet Earth are quite simple, though it probably took early people some effort and prolonged observation of the skies to suss out. A day is one complete rotation of earth. A month is a complete lunar cycle, from full moon to full moon, which averages about 29.5 days. A year is a complete planetary trip around the sun, which can be measured by charting the location of the stars in the sky, which move a bit each night and return to their original location after about 365 days.
Sumerian farmers in the Tigris-Euphrates Valley were probably the first to suss this out, about 5,000 years ago. They devised a yearly calendar of 354 days. This worked well enough for awhile, until their planting times clearly grew out of step with the seasons. They then altered the calendar, adding in days and even months over a 19 year cycle.
The Egyptians refined this calendar somewhat, recognizing that the average year has 365 days. Eventually, though, they ran into the same problem--seasons seemed to draft slowly out of sync with the calendar. Astronomers figured out how to correct the misalignment, namely by adding a day, what we know as a leap day, in every 4 years. The idea met resistance for some time however, until Julius Caesar decreed, in 44 B.C., that the calendar should carry the extra days.
It took a few thousand years to notice that this calendar wasn't quite accurate either. Easter, for instance, was slowly edging closer and closer to winter, in the Northern hemisphere anyway. In 1582, Pope Gregory the XIII shaved off some leap days -- henceforth, any 4th year divisible by 100 would not get one, though a year divisible by 400 would get a leap day. so, for example, 1600 and 2000 are leap years, but 1700 and 2200 are not.
To realign the calendar to the seasons, Gregory also removed 10 days from the calendar that year. As a result, October 5 through October 14 1582 never existed. The new calendar was called the Gregorian Calendar.
As instruments grew more precise and observations of the stars accumulated, other discrepancies made themselves known. The 24 hour length of day, for instance, could vary as much as 15 minutes a day. This variation is due to how earth travels around the sun in an ellipse -- so it travels faster in its orbit when closer to the sun -- and also, the earth is tilted by about 23 1/2 degrees in relation to the earth's orbit around the sun. Because of this yearly variance, which peaks in February, mean solar day was created, which averages out the time of all the days.