I found it helpful in some of my University math classes when I actually took the time to read the biographies that some of the textbooks included, the classes when I skimmed past them I did not remember details of the proof formulae for. But I don't know if this says more about the aid of history to the process of remembering or about my a priori interest in the topic for those particular classes.
For a really good example of integrating the history along with the mathematics, and much more accessible than those math texts, I would recommend "Journey Through Genius" by Dunham[0]. It may be a little dated (published in 1990) and its focus is limited to algebra, geometry, number theory, and the history is perhaps too Western-biased, but it's good and it's short. Its material would make a solid foundation to build on top of because, in addition to the historical context, it shows a lot of the thought process into approaching certain landmark problems.
For a really good example of integrating the history along with the mathematics, and much more accessible than those math texts, I would recommend "Journey Through Genius" by Dunham[0]. It may be a little dated (published in 1990) and its focus is limited to algebra, geometry, number theory, and the history is perhaps too Western-biased, but it's good and it's short. Its material would make a solid foundation to build on top of because, in addition to the historical context, it shows a lot of the thought process into approaching certain landmark problems.
[0]: https://www.goodreads.com/en/book/show/116185