It's more accurate to say that the Sun's gravity exerts a gravitational force on the Earth, causing it to orbit the Sun. This force is a fundamental force of nature that attracts any two objects with mass towards each other. The more massive an object, the stronger its gravitational pull.
While we often refer to the Sun's pull on Earth as "gravity", it's important to remember that it's actually the force of gravity that's acting between them.