Most mathematical textbooks start a subject by going backwards, historically. They will define the terms that were invented to solve a problem in their polished form and then use these definitions and structures to solve a problem towards the end of the book, if at all. This is conceptually clear but often obscures motivation.
One glaring example of this is Galois theory. The original solution of the problem progressed through steps that barely resemble the final product. While some motivation is given, I have not found any book that goes through the historical steps that led to galois theory.
I would like any articles or books that motivate subjects through their historical roots/problems. I think what I am really asking for is a book/article that focuses on problems used to generate theory rather than the construction of a general theory that is later used to solve problems. For instance, I would like a book/article that explains what Lame's approach to fermat's last theorem was and how it failed and led to ideals.
I am particularly interested in books that focus on algebraic number theory, but other fields are very welcome too.
Edit: Thanks for the comment, I forgot to mention that it is crossposted here