Is the earth slowly getting closer to the sun as it orbits it? If not, what keeps it from being drawn into the sun?
There are two main mechanisms driving the planets away from the Sun, according to http://curious.astro.cornell.edu/about-us/41-our-solar-system/the-earth/orbit/83-is-the-distance-from-the-earth-to-the-sun-changing-advanced.
First is the tidal friction effect. The Sun rotates on average about once per thirty Earth days (the Sun is not rigid and its rotation rate varies with latitude). The Earth takes about 365 days to orbit the Sun. As is better known with the Earth versus the Moon, the difference in periods of rotation and revolution means tidal friction transfers energy from the faster cycle (Sun rotating) to the slower one (Earth orbiting). So the Sun is gradually slowing its rotation and the Earth is slowly moving outward. The other planets are moving outward for the same reason. But the Sun is rather far away and its rotation is too slow to have a major impact. The source quoted above states that the tidal effect is pushing the Earth away from the Sun at only about one micrometer per year.
The second effect reported by Cornell University's site is the loss of mass the Sun experiences as hydrogen is fused to helium. The helium has less mass than the hydrogen it comes from, and the difference is the energy output from the Sun, according to Einstein's formula
With the recent verification of gravitational waves, we know that gravitational wave emission is tending to make the planets spiral inwards. But gravitational wave emission has almost no impact on the motion of the planets. Planets are moving so slowly and with such weak gravitational interactions that gravitational wave emission is ten orders of magnitude less than the direct effect of the Sun losing mass.
All told, the net result is the planets are moving away from the Sun, but only very slowly. As noted above, the dominant effect amounts to only 0.01% in a billion years for Earth.