Gravity attracts the planets to the sun.
In fact, the planets are constantly falling toward the sun in much the same way that a thrown ball falls down to the ground. When you throw a ball. If you throw the ball slowly, it lands on the ground a few feet from you, If you throw it faster, it will fall farther away. The faster you throw the ball, the farther it goes. Now imagine throwing the ball so fast that its path has the same shape as the curvature of the Earth.