For everyday purposes, there are exactly 86,400 seconds in a day (midnight to midnight). But, the rotation of the Earth about its axis and the path of the Earth around the Sun aren't exactly either uniform or stable. The rotation of the Earth is very gradually slowing, and there are a number of factors which make "midday" by solar observation sometimes more, sometimes less than 86,400 seconds from the preceding solar "midday". If you average over a solar year, sure, you'll get very close, but over a number of years, you'll see variation.
For scientific and engineering purposes, the fundamental unit for the measurement of time (the second) must have a fixed definition, not one that gets updated every few years just to keep in step with the occurence of solar midday. So, atomic clocks were developed to provide a stable reference against which the second can be defined once and for all (until or unless it is found that current atomic clocks are not a stable enough reference and there is some other measureable phenomenon which is even more stable).
For what it's worth:
Leap years have nothing to do with the second as a unit of time. Leap years occur because the rotation of Earth about its axis (from which we get our day) and the orbit of Earth around the Sun (from which we get our year) are not related by an integral number, and we want to keep our calendars in alignment with the natural day and year.
Leap seconds occur because we want to divide our mean solar day evenly into hours, minutes, and seconds, and the mean solar day is gradually getting longer (the Earth's rotation is gradually slowing), but we don't want to modify our definition of the second. Leap seconds are added on an "as-needed" basis, which occurs somewhat irregularly because there are a number of factors affecting the Earth's rotation.
A Brief History on Astronomy and the Measurement of Time
Long ago, humans found it beneficial to measure time. The first device to measure time was something like a stick in the ground; as the Sun appeared to move across the sky, the stick cast a moving shadow on the ground. Measuring the position of the shadow became the first measurement of time.
As the need arose for greater precision and accuracy, other devices were invented such as water clocks and eventually pendulum and balance wheel clocks. With the development of electronics, much greater precision, stability, and accuracy could be obtained. For some purposes, even greater precision and stability was required, and so atomic clocks were developed.
As clocks acquired ever improving precision, and the motions of Earth and other celestial bodies were measured to ever finer precision, it was found that Earth actually has many complex motions which affect the observed position of the Sun in the sky. The "first order" motions are the ones we all know - the rotation of the Earth about its axis and orbit of the Earth around the Sun. However, the Earth's orbit is not a perfect circle (it is an ellipse), and the parameters of the ellipse change over time. Also, the axis of Earth's rotation is not fixed - it undergoes a complex set of precessions over time. All of these things combine to make the true length of a solar day and even a year irregular. These variations are measurable with a sufficiently precise clock.
From a human, everyday perspective, the fundamental unit of time is the solar day, which we divide into hours, minutes, and seconds, giving us exactly 86,400 seconds per day. However, a day is not a fixed amount of time, so we have to make a choice about exactly how much time is represented when a clock measures off one second, so an observed solar day is only approximately that number of seconds. For everyday purposes, we accept the approximation and adjust our clocks from time to time to keep them in step with the solar day. For scientific purposes, the second is given a precise definition which approximates the familiar one, but is based on the most stable phenomenon we can usefully measure (such as the state transition of an atom).