Socialism seems to work better for the common man (despite the gripes from the common man about it that you sometimes see). Capitalism works better for elites, elitists, the lucky and fortunate, people of a certain mindset with "luck" on their side, etc, etc, etc.
The key game-changer was industrialism itself and how it impacted on the culture, demographics, and (ultimately) the politics where it originated and spread. Liberalism and concepts generally associated with the social welfare state came about mainly from elites who realized that they needed to keep the working classes reasonably content in order to make them less susceptible to socialist agitation. Leaders like Napoleon III and Bismarck supported social welfare policies for that reason, while using nationalism to unite and impel the masses. 1848 was a major wake-up call.
Such policies did work to a large extent, although not really because of the "system" itself. Competition was certainly a factor, but not really between companies or even families, but between nations who competed and fought with each other, such as between France, Britain, and Spain. Later on, Germany, Italy, and Russia would rise to prominence and join the game. America would also eventually find its way to the playing field, and Japan would come in as a latecomer. They were all capitalist and industrial states (although Russia was quite a bit behind for a variety of reasons), their populations grew, and they had industries and technologies to be able to equip and field some rather larger armies and navies (and air forces eventually).
That was capitalism, fueled by nationalism, which all came about from exploration and colonialism originally driven by a quest for "gold, glory, and God." And it did work, and for a time, it was good - for the elite, elitists, and the lucky and fortunate (and those who had no real conscience or scruples to dissuade them from committing the atrocities associated with that era). If you were a peasant and didn't relish the idea of working in a factory, you could always join a sailing crew - or perhaps go to America and stake a claim for free land (provided by government) which had just been recently cleared of Native "squatters" who actually believed the land was theirs. Still, a lot of people from the lower classes managed to elevate themselves this way, improving their standard of living and being able to eke out their own share of the American Dream.
It did work, and there are tangible results to prove that it worked, at least in terms of the expansion and development of America. We became very powerful relatively quickly - industrially, economically, and militarily. Likewise, it was working quite well in other places, such as in the British and French empires, and their good fortune was also spreading to their satellite states in Europe. The British were making a fortune from India and started making inroads into China - and other colonial powers were getting in on the action.
The competition between nations was not really planned, and many leaders felt compelled to do what they did not because they wanted to, but because they felt they had to. "If we don't do it, someone else will." Such as the annexation of Hawaii. We grabbed it before someone else could take it. Same with the Panama Canal. The European scramble for Africa is another example of the same process at work.
I would never deny or dismiss all that it took to bring the West out of the backward Medieval Era into the Industrial and Modern eras, and perhaps capitalism does work on that basis. It worked to build up the major empires of the world - although this global competition came with some downsides and serious issues that we're still dealing with today and will likely face for centuries to come (if humanity survives that long).
If you go back to say, 1910, and look at the world as it was back then, you might think it was some golden age of capitalism and the West. It must have been like ruling the world - and it seemed like it would go on that way in perpetuity. What could possibly go wrong, since they held the deed to most of the world? Those pesky socialists were nothing to worry about - just some wimpy intellectuals who are just full of talk (just like today). They might have had to throw a few table scraps to the industrial workers for PR purposes, but that was nothing compared to how much profit they were earning.
But, from the standpoint of Britain and France, their main fear at that point was Germany. Russia was also afraid of Germany, as they were largely still backward and unable to compete with German industries. Germany was quite powerful, and the Kaiser was kind of nutty. Nationalism was also at its peak, and one thing led to another, and the First World War was on.
My point in all of this is to say that, yes, capitalism does work, but there's a trade-off. There are certain costs and liabilities which come with it. This is why it gets messy and why there can be political upheavals and even world wars.
In other words, it's not really due to a "system" as much as it's rooted in the general way politics and commerce have generally operated. Nations which became wealthy and powerful due to industrialism and capitalism also operated from a certain practical and (when necessary) Machiavellian point of view.
However, having faced and dealt with the devastating wars, and the aftermath of colonialism and slavery, the various governments and peoples of the world said no more. We can't go on this way or else we'll wipe each other out. The socialists, at least those who reached the level of national power, for whatever reason, tended to become more quasi-nationalistic in their orientation and methods, which were atrocious and indefensible. They seemed to get more fixated on defending their revolution and ideology on a national level and trying to compete with the Western industrialists who had a 100-year head start on them. As a result, socialism suffered some setbacks.
At this point, I think America is at a bit of a crossroads - as we have been for quite some time. I think this may apply to much of the world, especially as concerns about climate change grow more and more urgent. The Democrats and the Republicans squabble with each other like cats and dogs.
I just don't know how much longer America can last under these conditions. Some people are worried about the possibility of America turning fascist, while others are worried about the possibility of America turning socialist. In other countries, nationalism is on the rise. It seems Russia has gone full tilt in that direction, but other nations are also showing signs of it. China isn't really communist or socialist anymore, but they are showing definite trends towards nationalism. And in America, we have Trump and other America Firsters riling things up.
What seems evident at this point is that, for whatever reason, liberal capitalists appear somewhat hobbled in trying to bottle up and rein in some of the more brazen right-wing conservative capitalists. The liberals just can't seem to cut the mustard; they're not getting the job done. It's not because their heart isn't in the right place, but I think that they've grown soft and complacent and they don't really want to rock the boat too much. Fact is, many people are multiply-connected and dependent upon the system, while hoping to work within the system to bring about reform. But under current conditions, the system itself is weakening.
To me, the argument is not really about what system is better. It's more a matter of politics and what is practical under present conditions. I think it's a matter of weighing up the costs and benefits of various policies and proposals, on a practical basis, rather than an ideological one.