When looking at a calendar, one of the first thing that springs forth is the oddity that each month has a seemingly random amount of days. Why are the number of days in a month not equal? And why are they distributed the way they are? To answer that question, we have to look a bit at the history of the modern calendar.
Our calendar, the Gregorian calendar, is a reformed version of the Julian calendar. The Julian calendar, in turn, was a reformed version of the Roman calendar. It was during the reign of Julius Caesar that the calendar was realigned drastically, to make it function somewhat more seamlessly.
Before the Julian reform, the number of days in a month was as follows: Ianuarius was 29 days, Februarius was 28 days, Martius was 31 days, Aprilis was 29 days, Maius was 31 days, Iunius was 29 days, Quintilis was 31 days, Sextilis was 29 days, September was 29 days, October was 31 days, November was 29 days, December was 29 days, and there was an Intercalaris month which was 27 days long.
In the new Julian calendar, the Intercalaris month was abolished entirely, and the number of days changed for the shorter months. Those months which already had a length of 31 days remained the same, while Ianuarius, Sextilis, and December each gained two days, and Aprilis, Iunius, September, and November each gained one day, while Februarius remained the same, although it gained one extra day every four years, to equalize the calendar somewhat. Quintilis was later renamed Iulius in honor of Julius Caesar, and Sextilis was renamed August in honor of Augustus Caesar.
Looking at the older Roman calendar, it is apparent that the number of days in a month was already irregular. This is because of some shifts that happened between the early Roman calendar and the later Roman calendar. Originally, the Roman calendar was a lunar calendar, meaning that the length of each month was roughly based on the moon. The time between two new moons is roughly 29.5 days, so months were either 29 or 30 days long. Those months with 29 days were considered unlucky, those with 30 were considered lucky.
The number of days in a month in the Roman tradition were not calculated quite the same as we calculate them today. Instead of counting up from one to 29 or 30, the Romans counted from the time the new moon was first spotted after sunset, and depending on the orientation and shape of that thin crescent, the number of days to the mid-point when the moon was at half full would be determined.
The first truly formal Roman calendar had already departed from a true lunar calendar, although the days were much more evenly spaced than our current calendar. The calendar had only ten months, and the number of days in a month were as follows: 31 days in Martius, 30 days in Aprilis, 31 days in Maius, 30 days in Iunius, 31 days in Quintilis, 30 days in Sextilis, 30 days in September, 31 days in October, 30 days in November, and 30 days in December. In addition, there were some 61 days during the winter that were not part of any particular month.
Things got further complicated in the late-8th century BCE, because of a Roman superstition that held even numbers to be unlucky. One of the traditional Kings of Rome, Numa Pompilius, decided to reform the calendar to make as few months as possible have even numbers of days. His first reform added two months, January and February, to the end of the calendar, and made all the months, save February, have odd numbers of days. This made the calendar roughly alternate in the number of days in a month: 31, 29, 31, 29, 31, 29, 29, 31, 29, 29, 29, 28.
A popular apocryphal legend dating from the 13th century tries to simplify the reasons behind the number of days each month drastically. It holds that originally the Julian Calendar was regular, with month lengths alternating: 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29. The theory holds that Caesar then added one day to every month except February, to fill out the calendar. The theory further stipulates that during the reign of Augustus Caesar, August was changed to have 31 days, in order to match the length of July. This theory has ample evidence disproving it, including older irregular Roman calendars. Whatever the motivations of the ancient Romans to make their calendar irregular, it was probably not connected to the hubris of Augustus Caesar.