Here is the rule. A year is a leap if:
It is divisible by 4
It is not also divisible by 100
Unless it is divisible by 400
This means that years such as 1992, 1996 are leap years because they are divisible by 4 and are not affected by the rest of the rule which applies to century years such as 1900 and 2000. Century years are not leap years except where they are a multiple of 400. Hence, the years 1700, 1800 and 1900 were not leap years and did not contain a February 29. But the year 2000 will be a leap year, the first such century leap year since 1600. However, in 4000 there will be no leap year, because of the odd fact that there is an extra day or so, every 125 years.
It's a long story that really should begin with the Thoth calendar invented in Egypt, 5000 years ago. From it, and the ancient Roman calendar, Julius Caesar developed a better one. He and his nephew, Augustus who succeeded him, were chiefly responsible for the names of the twelve months in our calendar, the numbers of days in those months, and for leap year.
The Julian calendar is named after Julius Caesar, and between its introduction in Roman times and the middle ages in Europe there was an appreciable drift in the seasons. This forced a reform of the calendar by Pope Gregory in 1582, with 10 days were left out of October of that year (with some anguish) to bring the seasons back in phase. It took some time for this system to be introduced in Britain from Europe and this did not occur until 1752. Imagine the confusion of not only a time change when travelling but also a different date.
Why do we still need leap years today, and why the strange rule? The need for leap years arises from the fact that the time taken by the earth to orbit the sun (the year) is not an exact number of days - the length of the day being determined by the spin of the earth. This incompatibility is somewhat inconvenient for calendar making, causing it to be more complex.
The exact length of the year (i.e. the revolution of the earth around the sun) is 365.2422 days. If we had a calendar with years having only 365 days then the seasons (which are determined by the rotation of the earth around the sun) would drift by a quarter of a day in every year. This might seem small, but after a 100 years the seasons would have drifted by 25 days and very quickly there would arise the situation where summer is occurring when winter used to!
A first improvement is the Julian calendar in which there is a leap year every four years. This means that the average calendar year is 365.25 days which is closer to the real value but still too long. Even in this system, the seasons drift by one day in every 128 years.
We use the Gregorian system at present with its rule for leap years as given earlier. In the Gregorian calendar the length of the calendar year averages 365.2425 days which is very close to the true year of 365.2422 days. The drift in the Gregorian calendar is only one day in around 3300 years. With it, we will not need to worry about calendar reform again for some considerable time.
The original Roman calendar had a 10-month year of only 304 days. It began in Martius at the time of the vernal equinox. The second month was Aprilis, followed by Maius, Junius, Quintilis, Sextilis, Septembris, Octobris, Novembris and Decembris. Numa Pompilius, successor to the legendary Romulus, took care of the other 61 days by adding Januarius and Februarius.
The Russian Orthodox Church still uses the Julian calendar. Christmas comes out about January 7 in their calendar. About every century, the Orthodox Christmas slips one more day against the solar calendar. There is a 13 day lag until 2100 when it will become a 14 day lag.
The Jewish calendar is based on a lunar cycle (that is, each month is based on moon, about 29 or 30 days, from new moon to new moon. Since the Jewish holidays are supposed to be season-related the calendar adjusts by adding a whole month, about every three years.
The Muslim calendar is also lunar, but it doesn't adjust. Thus, the holidays come about 11 days earlier in the season each year. Some years, Ramadan comes out in the spring, then in winter, then in fall. It takes about 35 years for everything to cycle round again.