I found it amazing how Newton figured out his theory of gravitation $(GMm/r^2)$ using Kepler's laws. The next logical question was how Kepler deduced his laws. This leads you to a rabbit hole of incorrect astronomical models. Aristotle, Ptolemy and Copernicus all developed incorrect models. It was, however, impossible for Kepler to find his laws without these models. In fact, Kepler produced a few erroneous theories of Mars's orbit around the Sun himself before narrowing upon the shape of an ellipse.
I've come to realize that the study of Physics is incomplete without understanding the history behind its development. So, now, I'm interested in understanding the ancient models of the heavens. What were these models? What mathematics went behind them? What experimental data justified them? Additionally, I am most interested in the work of Kepler and how he built his three laws using the data that were available to him.
In essence, I'm looking for a "history of science" book. Unfortunately, most such books are biographies of scientists as they hardly get down to the real mathematics and reasoning that went behind the models and theories. So, now, I'm not sure of the resources that would help me in this path (for context, I'm a freshman in University). Are there any books that would help me in this learning journey? Any guidance would be greatly appreciated. Thank you.