The gravitational force is responsible for providing the necessary centripetal force. The earth is also moving tangential and when the sun’s gravity is acting, it pulls earth towards itself, hence changing the trajectory of the earth. But due to tangential movement of the earth in sun’s frame, the earth does not fall into the sun.