The sun's gravity is 28 times that of the Earth's. The more mass an object has, the stronger its gravity will be. Therefore the sun attracts the Earth towards it and the sun's gravity is responsible for the Earth's regular orbit through the solar system.
The Earth travels at a velocity that approximates the force the sun exerts on the planet, resulting in a regular orbit. The variation in the strength of the sun's gravitational pull from the side of the earth facing towards the sun to the part facing away is partly responsible for the tides of the ocean.