How did people know that the Earth orbits the Sun, before gravity was widely accepted?
The notion that the Earth revolves around the Sun was first proposed in the 3rd century BC by Aristarchus of Samos. However, it was not until the 16th century that a fully predictive mathematical model of a heliocentric system was presented, by mathematician and astronomer Nicolaus Copernicus. In the following century, this model was elaborated and expanded by Johannes Kepler and supporting observations made using a telescope were presented by Galileo Galilei. Basically, it was all about observations and calculations, with the ability to come to the right conclusions.
Newton didn’t “discover” gravity. People have known that things fall for a long, long time. Newton just figured out why the moon hasn’t fallen and crashed into Earth. Heliocentrism dates to the ancient Greeks, it’s true, but that was apparent in calculations of orbits for centuries when orbits were thought to be circular, or nearly so, and it wasn’t until Newton that the elliptical orbit had a solid basis linked to a universal gravitational force.