The Earth is always being pulled towards the Sun by gravity. If the Earth were stationary compared to the Sun, it would fall into the sun under the force of gravity. However the Earth is actually moving sideways compared to the center of the Sun at 3 km/second (~2 miles/second). The Earth is not moving fast enough to "escape" the Sun's gravity and leave the solar system, but it is going too fast to be pulled into the Sun. Therefore, it keeps going around and around - orbiting the Sun. It is rather like a tether ball. Think of the top of the post as the Sun and the ball as the Earth. The string between them is like the force of gravity keeping them the same distance apart. When you hit the tether ball it spins around the post. If there were no air or rope friction, the ball would spin forever without getting any closer to the post. That is essentially what the Earth is doing when it orbits the Sun - it the vacuum of outer space, it does not loose speed to air friction, so it just keeps going around the Sun.