Excellent question. The thing to keep in mind is that the planets start with some motion perpendicular to the sun. To see why this matters, let's take two cases:
If the planet had no motion relative to the sun, and just sat there, what would happen? Well, it would accelerate directly at the sun, and keep doing so until it crashed straight into it.
If the planet was moving perpendicular to the sun, but the sun for whatever reason no longer exerted a gravitational force on the planet, what would happen? Well, the planet would keep moving in a straight line, away from the sun forever.
But in reality, a mixture of these two things is happening. The planet will need some velocity in order to not fall into the sun. How much? Well, now we have to do some math.
You can describe the force needed to keep an object moving in a circle by the equation F = m*v^2/r, where m is the mass of the object, v is its speed, and r is the radius of the circle. This equation is the reason you feel pressed against the side of a car when it turns sharply - it exerts a force on you in order to change your direction. You may have heard of it, it's called 'centripetal force'
Now, we also know that the force of gravity is described by F = G*M*m/r^2, where M is the mass of one object (the sun in this case), m is the mass of another (the earth), r is the distance between the two.
If the earth is not falling into the sun, the force from our rotation must be exactly cancelling out this force from gravity. F(centripetal)-F(gravity)=0
You can now set the two equations equal:
mv^2/r = GmM/r^2
And solve for v
v = sqrt(GM/r)
This is the velocity the earth needs in order to not fall into the sun. Let's see if our predictions match reality:
G is the gravitational constant and has a value of 6.67 x 10^-11
M is the mass of the sun and has a value of about 1.2 x 10^30 g
r is the radius of Earth's orbit and has a value of about 150 million km
If you plug in the numbers, you find that v = 29,732 meters per second, if our equations are correct.
Well, we've been able to measure exactly how fast the earth does go around the sun, in real life. Turns out to be 29,780 - so our equations predicted reality to within .1%! isn't that amazing?