Because the Earth takes 23 hours and 56 minutes to complete an orbit around the Sun, but we want a calendar that has 365 days! So every four years we add an extra day, to keep our calendar in sync with the Earth’s orbit. It’s like an accounting adjustment that allows everything to balance out nicely.
The leap year was originally instituted to account for the fact that the Earth is not orbiting the sun perfectly–it’s slightly tilted, which means that every four years the planet is a little bit off kilter.
It’s kind of like the planet needs a little bit of a “do-over” to make sure that it’s aligned correctly with the sun.