The Problem with the Old Julian Calendar
Before 1582, most European countries were using the Julian Calendar set by Julius Caesar in 46 B.C.E. At first glance, it would sound simple and right, as it follows a year that has 365.25 days, with a leap day being added to the calendar every 4 years. However, the real length of the year is about 365.2422 days.
In other words, every year, the calendar is being pushed slowly by about 11 minutes and 14 seconds. At first, that error was tolerable, but after nearly a thousand years or so, the Christian Church began to face some problems. The easter and other holidays were slipping away from the seasons of the year that they are supposed to happen in. This prompted the Pope to decide on a fix.
Read more: Wikipedia
How Pope Gregory XIII Decided to Fix the Calendar
To solve their problem, Pope Gregory XIII commissioned the astronomers and mathematicians to come up with a better calendar system. They created the Gregorian calendar, which states that centuries not divisible by 400 will not be leap years. This meant that 1600 or 2000 were leap years, but 1700, 1800, and 1900 were not. This new system fixed the problem, as the average year was now 365.2425 days, which is very close to the real solar year, matching the holidays and the seasons.
But, there is one more problem left. Changing the calendar should fix the future issues. However, it would not do the same for the 10 days that have already built up over the years. So, catholic countries such as Spain, Portugal, Italy, and Poland followed the reformers and skipped 10 days. They selected October due to its low major religious festivals, and it also did not disrupt the winter and spring seasons in the calendar.