Since the earth is constantly attracted towards the sun by the gravitational attraction, why does it not collapse into the sun and burn up?

OR: Force of attraction is acting on the earth due to sun but it does not collapse in the sun. Why?

The earth is constantly attracted towards the sun due to gravitational force. At the same time, the earth is also trying to move straight ahead because of its speed and inertia of direction. Being in a circular orbit means that the path of the earth is balanced by equal inward moving tendency as well as the outward moving tendency. So, the earth does not collapse into sun and also does not get farther from the sun.

Mathematically, the earth is accelerating towards the sun such that the force of gravity exerted on earth by the sun is completely balanced by the centripetal force of the earth.

$\text{i.e.}\;\;\frac{GMm}{d^2}=\frac{Mv^2}{d}$ where $d$ is the radius of the circular orbit of the earth.