Hardy felt the need to justify his life's work in mathematics at this time mainly for two reasons. Firstly, at age 62, Hardy felt the approach of old age (he had survived a heart attack in 1939) and the decline of his mathematical creativity and skills. By devoting time to writing the Apology, Hardy was admitting that his own time as a creative mathematician was finished. In his foreword to the 1967 edition of the book, C. P. Snow describes the Apology as "a passionate lament for creative powers that used to be and that will never come again". In Hardy's words, "Exposition, criticism, appreciation, is work for second-rate minds. [...] It is a melancholy experience for a professional mathematician to find himself writing about mathematics. The function of a mathematician is to do something, to prove new theorems, to add to mathematics, and not to talk about what he or other mathematicians have done."
Hardy believed that he could no longer be actively involved in the evolution of new mathematical ideas; as he wrote,
"I write about mathematics because, like any other mathematician who has passed sixty, I have no longer the freshness of mind, the energy, or the patience to carry on effectively with my proper job." thus the only thing left that he could contribute to mathematics, as he believed, was to write a book about mathematics in which he could express his personal views on the subject.
Secondly, at the start of the Second World War, Hardy, who was a committed pacifist, wanted to justify his belief that mathematics should be pursued for its own sake, rather than for the sake of its applications. The act of pursuing mathematics for the sake of their purity, for their internal perfection and for the clarity of their underlying concepts. He wanted to write a book in which he would explain his mathematical philosophy to the next generation of mathematicians. A book that would defend mathematics on the basis of their endogenous importance, by elaborating on the merits of pure mathematics solely, without having to resort to the attainments of applied mathematics in order to justify the overall importance of mathematics; a book that would inspire the upcoming generations of pure mathematicians. As Hardy was an atheist, he makes his justification not to God but to his fellow man. One of the main themes of the book is the beauty that mathematics possess, which Hardy compares to painting and poetry. For Hardy, the most beautiful mathematics was that which had no applications in the outside world, by which he meant pure mathematics, and, in particular, his own special field of number theory. He justifies the pursuit of pure mathematics with the argument that its very "uselessness" meant that it could not be misused to cause harm. On the other hand, Hardy denigrates applied mathematics, describing it as "ugly", "trivial" and "dull".
These characterizations concerning applied mathematics mean that it is not the fact that they are applied that makes them "ugly", "trivial" and "dull" but it is because more often the most "ugly", "trivial" and "dull" mathematics are usually the ones finding application. These characterizations are attributed or not to certain branches of mathematics in accordance to the originality, depth and beauty of the underlying concepts that constitute the foundations of these branches as defined by G. H. Hardy. This is further stressed by Hardy in his comments about a phrase attributed to C. F. Gauss that "Mathematics is the queen of the sciences and number theory is the queen of mathematics". Some people believe that it is the extreme non-applicability of number theory that led Gauss to the above statement about number theory; however, Hardy points out that this is certainly not the reason. If an application of number theory were to be found, then certainly no one would try to dethrone the "queen of mathematics" because of that. What C. F. Gauss meant, according to Hardy, is that the underlying concepts that constitute number theory are deeper and more elegant compared to those of any other branch of mathematics.
His beliefs on pure mathematics seem to be summarized in the following excerpt from the book,
"Pure mathematics, on the other hand, seems to me a rock on which all idealism founders: 317 is a prime, not because we think so, or because our minds are shaped in one way rather than another, but because it is, because mathematical reality is built that way."
Another theme is that mathematics is a "young man's game", so anyone with a talent for mathematics should develop and use that talent while they are young, before their ability to create original mathematics starts to decline in middle age. This view reflects Hardy's increasing depression at the wane of his own mathematical powers. For Hardy, real mathematics was essentially a creative activity, rather than an explanatory or expository one.
Some of Hardy's examples seem unfortunate in retrospect. For example, he writes, "No one has yet discovered any warlike purpose to be served by the theory of numbers or relativity, and it seems unlikely that anyone will do so for many years." Since then, the application of relativity was part of the development of nuclear weapons, while number theory figures prominently in public-key cryptography. However, Hardy's more prominent examples of elegant mathematical discoveries with no use (proofs of the infinity of primes and the irrationality of the square root of two) still hold up.
The applicability of a mathematical concept is not the reason that Hardy considered applied mathematics somehow inferior to pure mathematics, though; it is the simplicity and prosiness that belongs to applied mathematics that led him to describe them as he did.
He considers that Rolle's theorem for example, though it is of some importance for calculus, cannot be compared to the elegance and preeminence of the mathematics produced by Leonhard Euler or Évariste Galois and other pure mathematicians.