What is meant by learning math historically (not learning math history only, but learning math with a historical development perspective)? I've seen some sources mention that to learn a math topic X, you need to look at the historical development of the topic X and go over the famous questions by yourself to develop a good understanding of the subject (to quote exactly the source: "read the author, reproduce the results in your own way, and think about it to internalize, and repeat for the entire history. Also, don't get stuck, if you are stuck, move on to something else and come back. Time is limited").
I also find this method (learning in a historical context) nicer because more often that not traditional books (say a book on Group theory) starts like here are the axioms (eg the group axioms), memorize it and look at the theorems and corollaries which follows from the axioms. Without the historical context it keeps me wondering what was the point of the axioms in the first place (i.e what motivated the definitions in the first place).
But on the other hand, regarding learning things historically, how I am supposed to "go over the famous questions by myself" when the problems took tens of years to solve ?
For a concrete example, I'm learning Ring theory now. What should I do to learn it in a historical way ? Am I supposed to work on problems like $x^3+y^3 = z^3$ or UFD over cyclotomic integers and "rediscover" Ring theory ? But how I am supposed to sensibly work on the problems without knowing the theory when they took really long time to solved in the first place ? Or "learning math historically" is done just like reading math from textbook, you just "passively" read the history of how some ideas were developed instead of "actively" working on some historically important questions which took really long time to solve ?
I also want to know whether this is a good approach.
EDIT: My main focus is not on the books which approaches mathematics historically (though book recommendations are very much welcome ! But they should be in comments section rather than as a stand alone answer) but on the method itself.
Here I'd like to address three books with a dedicated historical development perspective. Since OP's question is highly opinion based I think it might be helpful to look at some statements from the authors themselves, in order to get an impression how this subject should be treated.
In the same spirit the author has also written A Radical Approach to Lebesgue's Theory of Integration.
The next one is a classic from a famous mathematician which is already an essential part of mathematical historical development.
The last one is from an author which was (and is) important for me when I was a student.
In the same spirit the author has also written Classical Topics in Complex Function Theory, which can be seen as volume II of the former book.
[Add-on]: Some thoughts
OP's quote: "... read the author, reproduce the results in your own way, and think about it to internalize, and repeat for the entire history ..." is not a challenge to reinvent some theorems, mathematical structures or concepts.
The books referred in this answer provide many examples in appropriate historical context which can be formidably used to study and train this way the own abilities by grasping the essential ideas and trying to reproduce them independently.
The development of mathematical ideas is by far not only a single thread connecting a point $A$ in the past and another point $B$ in later times.
... and even this is a simplified description, since there are many superpositions of ebb and flow with respect to different ideas in mathematics.