Using Google, I located
in "Curious about Astronomy? Ask an Astronomer."
"If it takes the Moon 28 or 29 days to orbit the earth why are most months 30 or 31 days long?
This has resulted from a compromise. Initially, months were mostly 29 days long and the average length of a month was 29.5 days which is the time taken by the Moon to orbit the Earth. However, this resulted in a year of only 354 days while the orbital period of the Earth is 365.2422 days. As a result, the calender became out of sync with seasons which was bad. This was initially corrected in an arbitrary way by adding a 13th month, but soon the calender was thrown into severe confusion.
In 46 B.C., Julius Caesar reformed the calender by ordering the year to be 365 days in length and to contain 12 months. This forced some days to be added to some of the months to bring the total from 354 up to 365 days. To account for the extra 0.2422 days, every fourth year was made a leap year. This made the average length of a year to be 365.25 days.
However, the Julian year still differs from the true year and by 1582, the error had accumulated to 10 days. So, 10 days were dropped from the year 1582 so that October 4, 1582 was followed by October 15, 1582. In addition, a modification was made that century years that were not divisible by 400 would not be considered as leap years. For example, 2000 would be a leap year while 2100 would not. This made the year sufficiently close to the actual year and this calender is called the Gregorian calender.
As the year is now set up to follow the seasons accurately, it no longer follows the phases of the Moon.