With seemingly nothing I mean that I don't doubt there were so many philosophers and scientists reaching nothing. No breakthroughs, no major contributions to science. Also, I believe some philosophers' theories also might've made sense or well-perceived only hundreds or even thousands of years later.
I find it hard to believe that many of these had an actual job. E.G Nicolaus Copernicus ploughing the land, or Plato selling fish at the market in between his teaching Aristotle.
So, who was seemingly stupid/mad enough to pay for the upkeep of both the very famous and not so famous philosophers and scientists of old? In retrospect it was a good investment for mankind, but surely it'd be a bad investment if there were no immediate profits to be gained?
This is going to depend on the specifics of time and place, and your examples range from Ancient Greece to the early modern period (Copernicus). These are places hugely separated by time and space, and the answers are going to vary a lot.
One way to think about the history of science (and philosophy, to an extent) is about the changing patrons of knowledge-producers. (This is in fact a common final exam essay question I have give my undergraduates when I teach the history of science — "synthesize a narrative of the entire course based around the topic of scientific patronage.) Depending on when you are talking about, the patron can be the state/government (this holds for many pre-modern societies, such as the Ancient Babylonians, much of the history of Chinese science, and to some degree Abbasid science), religion (this would be the case for Copernicus — he was a canon in the Catholic Church — and the line between religion and government is blurred in many cases, like the Abbasids and Babylonians), universities (if you are talking about Europe after the 11th century, though they were not typically sites of research until much later), nobility of different levels (Brahe was a Danish noble, supported by the king; Galileo courted the Medicis' favor), and so on.
In societies that did not have a very well-established system for funding this kind of work, you find the practitioners tend to be independently wealthy (e.g. Darwin), working for the very wealthy (e.g. Galileo, again), or otherwise managing to sell their services (Aristotle was born wealthy, but also taught students for money).
As for immediate profits, in many cases there were immediate profits, in the sense of useful returns. The Babylonians didn't fund technical work because they thought it was interesting, they did it because it was necessary to keep their civilization afloat. The Abbasids sponsored huge translation projects of secular, foreign knowledge because they thought there would be benefits down the line — places like medicine, for example. The Chinese (and many others) were interested in astronomy because they thought you could use it to predict the future (astrology) — that's pretty practical, if it worked!
But you are right that many of the gains were somewhat intangible. The Medici's funded Galileo mostly because it showed how powerful and important they were, like keeping a few great artists in your "stable." He was a feather in their cap. (He also did some practical things for them, like educating their scions in how to use tools for the calculation of artillery trajectories, for example. But these are not why they primarily kept him around.) In the environments where religion was a motivation, it was because there were beliefs that this kind of natural knowledge would enhance the knowledge of God. And sometimes it was just an intellectual fashion — an ethos that certain types of knowledge were worth funding.
And of course sometimes the science/knowledge in question existed in spite of these systems, as it does today. Oh, the reward system wants X? OK, let's dress up what we're really interested in as X, but it's really Y. So it's not always a simple thing for any individual. Copernicus' work on the solar system was officially an off-shoot of Catholic interests in astronomy that included questions about the reformation of the calendar; but his actual motivations for doing it were probably more varied (he was a something of a Pythagorean sun-worshipper).
So this is just the broad outline of an answer, and one that only skims the possibilities. You are essentially asking, how did the communities of science work prior to the modern period? Which is a very big question. And you don't really need to cut it off at the modern period, as if that was straightforward — we have a diverse means of funding science globally today, on a scale that is considerably larger than what was funded in the past, and which has undergone many changes in even just my lifetime (the end of the Cold War changed funding patterns dramatically in the USA, and certainly in many other nations; there's a reason the USA doesn't build giant particle accelerators anymore!).
And we definitely fund things that are not expected to turn an immediate profit (even industry, at times, has had long-term research interests — see e.g. Bell Labs — though those are less common these days). We even fund some things that proclaim to be gloriously impractical (frequently this falls to philanthropy, though universities in general can be thought of supporting this, using pedagogy as the main motivation for salaries). I always leave my students with the notion that one thing that is a constant in the history of science is that you find that the type of reward system for science in various ways shapes (to degrees both subtle and not) the type of science you end up with. So what kind of science should we be expecting to get, given our current world?
(My favorite example of this is the mapping of the sea-floor during the Cold War, which was funded lavishly. Why? Because the superpowers wanted to know where to hide submarines. By comparison, the funding of pure research into, say, menopause, has been far more paltry.)