Mathematics is the name of a discipline, and it also describes a realm of numbers, concepts and relationships that seem, on occasion, to have some connection to how the work works.
Of course, mathematics as a discipline, or area of study, was invented, in the same way archeology, linguistics or neuroscience was invented. But the things that such disciplines concern themselves with are more open to the question of whether they were invented or discovered.
Does number '2' exist, or have we just invented it as an abstraction to represent 'twoness'?
Mathematics itself is composed of many parts, and some of these parts might have different answers to this question than others. For example, can we say that two things exist independently of human observation? Many (but not all) people would be happy to say that the Earth and the moon existed as two things before people came on the scene. But what about the number ‘2’ itself? Does that exist, or have we just invented it as an abstraction to represent 'twoness'? Much of ancient Greek thought gave the numbers a very firm status as real, and the Pythagoreans even thought they were living things.
Complex mathematical concepts, some of which have been worked out without any thought to whether they have any utility, have ended up being very useful in describing how the world works. The physicist, engineer and mathematician (for they are not necessarily the same things) Eugene Wigner wrote an essay called “The Unreasonable Effectiveness of Mathematics in the Natural Sciences” which spoke to exactly this point: if mathematics is just made up, then how come it works so well in giving us a deep understanding of the nature of reality?
Others suggest that, in fact, mathematics fails to describe some very significant aspects of the world, not just physical, but also those things associated with value. In this framing of the role of mathematics it is just a set of rules no more special than those of chess, say, which, while enabling some very interesting things to happen, ultimately are a product of nothing more than human psychology.
Indeed, the philosopher Immanuel Kant though the order apparent in the world around us could be in its entirety a function of the ordering capacity of the human mind, and that everything, right down to basics ideas such as case and effect, past and present, are the minds attempts to impose structure onto an otherwise incomprehensible reality whose ultimate nature was, even in principle, unknowable.
Mathematics is grounded in a branch of philosophy called Logic, and the question of invention or discovery can also be applied here. John Stuart Mill in his work “System of Logic” made a distinction between how we reason, which is an empirical discovery, and how we ought to reason, which involves prescriptive statements based in part on logical rules. Those who think these rules could not be understood as independent of our psychology subscribe to “psychologism”. Even though these rules may have been invented by us, they are nevertheless products of a natural process (i.e. our minds). It is this appeal to the naturalism of our own minds that can also be applied to mathematics.
In some senses, then, mathematics is understood by some as a discovery of relationships in nature, even thought the symbolisation and expression of those relationships is entirely constructed by us. For others, it’s all a product of our psychology, yet still a natural process. For still others, mathematics has no more special status than road rules (which can make its “unreasonable effectiveness”, if that is accepted, problematic). Which of these, or other articulations of the problem (for there are many others) may be true, if any, is still open to debate.
Perhaps the easiest response is the most unsatisfying one taken by most people—it works, let's just get on with it.