A common misperception is that the case for free markets rests on the assumption that markets are perfect. The free market supposedly always through "the invisible hand" always comes to the right decision in all economic activites.
That straw man version of the case for free market is clearly false, yet it is sustained both by neoclassical micro economists and New Classical macroeconomists who use these kinds of models. And since these models are obviously false, leftist/Keynesian economists makes sure to always present them as the case for free markets, something which they can easily refute.
A more proper case for free markets goes something like this: All people are imperfect, which is to say they aren't omniscient or infallible. As such, they are likely (indeed almost certain) to do things which at least in hindsight can be shown to be mistakes. I’ve made a lot of mistakes in my life, and that probably goes for everyone. For this reason, market processes will inevitably result in outcomes which aren't optimal. Something which by some people would be referred to as market failures.
However, just because markets often fail to produce the best possible outcome doesn't mean that there is a case for increased government intervention. People working for the government are likely to be as imperfect as people working for private companies, and they will therefore produce a lot of what one might call government failures.
The really relevant issue isn't then whether or not markets or governments are "perfect", as neither clearly isn’t. The issue is which system has a structure that will reduce or increase the number of bad outcomes.
The free market has such a structure. If a company decides to invest in the production of a product that no one wants (at least not at a price which would cover the cost of production), then it will automatically be punished by suffering losses. If it on the other hand had invested in products that people wants then it will automatically be rewarded by profits. Similarly, if someone makes the foolish decision of spending their entire monthly paycheck in night clubs and bars in a wild weekend, they will be unable to pay their bills and will be forced to live the rest of the month on leftovers or low price food they really don't like, unless they can come up with some new income (which would be a good act rewarded by the market).
It is true that even the market structure, and not just the people in it, is imperfect. By that I mean that if someone makes a foolish decision, sometimes others will unfairly suffer too. If some employer for example decides that for some reason (cronyism, irrational hiring practices or whatever) that a less competent job applicant or contractor should be hired instead of someone more competent, then the market process will punish the employer (because he has less competent workers or contractors), but the more competent job applicant or contractor will also suffer. But that problem will exist in any human interaction, that bad decisions will hurt more people than the people making the decisions. It certainly applies to governments hiring employees or contractors too.
But at least the market process will punish those responsible too, because government officials are funded by compulsory taxes (or loans or printed money), they will not necessarily suffer if they make bad decisions. Whether or not government officials make the right or wrong decisions, they will have the same income.
Some might object that for democratic governments, a similar process exists. Namely, that if government officials cause problems, then voters will elect new ones. That argument is partly true, and that is one reason why a democracy is preferable to a dictatorship.
However, while better than a totalitarian government, elections don't work as well as markets for two reasons. First of all, because in a market everyone gets what they want while in elections it often just a slim majority that gets what they want, while the rest is not pleased. And secondly, because the economy and other political issues are usually quite complex and not really something which most people truly understands. For example, even though government intervention caused the Great Depression, it resulted in further expansion of government intervention. By contrast, people usually understand clearly whether or not goods and services they buy in the market place are good for them.
In short, both markets and governments are imperfect. But the market process is much more likely to reduce the number of suboptimal or imperfect outcomes than government control is.