Why did science challenge the view that the Earth was at the center of the universe?
Because it simply didn't fit the data! This is what science does best---it overturns beliefs that are widely-held but inconsistent with observed data.
The theory of geocentrism, on which the Earth was the center of the universe and cosmic bodies orbited around it, was intuitive to most people, and as a result it was in place for centuries. Before precise measurements were possible, this theory was close enough for most purposes; there were some weird anomalies like the retrograde motion of Mars, but there were ways of sort of fudging the theory to make it work well enough, such as epicycles where orbits were actually orbits within orbits, multiple layers on each other so that they could occasionally move the opposite direction for a short period.
But as measurements became more precise, this fudging of the theory became more and more untenable. A new theory was needed, and ultimately proposed by Copernicus and then advanced by Galileo. On this theory, heliocentrism, the Earth and other planets all revolve together around the Sun. Heliocentrism was a much more parsimonious explanation for observed cosmic motions than the epicycles, but it still did not catch on immediately, in part because the Catholic Church had committed to geocentrism as the official (and ostensibly, infallible) view of the Church. Moreover, Galileo's theory of circular heliocentric orbits still didn't quite work, though it was better than the old theory.
It wasn't until Kepler realized that the orbits were not circles but ellipses that finally the heliocentric theory won, because then it completely accounted for all observations in a simple and elegant theory. Kepler's theory was very precise for its time, and we wouldn't discover any errors in it until centuries later, when extremely precise measurements supported Einstein's theory of General Relativity instead. The difference between the two was so small it took 20th-century instruments to even detect it.
For their part, the Catholic Church finally admitted Galileo was right... in 1992.