It is a leap year if the year is exactly divisible by 4 and is not divisible by 100 unless it is divisable by 400.
The calendar year is 365 days long, unless the year is exactly divisible by 4, in which case an extra day is added to February to make the year 366 days long.
If the year is the last year of a century, eg. 1700, 1800, 1900, 2000, then it is only a leap year if it is exactly divisible by 400. Therefore, 1900 wasn't a leap year but 2000 was.
The reason for these rules is to bring the average length of the calendar year into line with the length of the Earth's orbit around the Sun, so that the seasons always occur during the same months each year.