but that doesn't change the fact that they are robber barons.
Or "robber barons" concept is a socialist myth. In fact the companies founded by these people generally pushed forward technological or business solutions that revolutionized the economy and made people's lives better. For instance, Standard Oil dramatically decreased the price of oil products (not what you'd expect from a "monopoly").
"Robber barons" is a concept invented by their inefficient competitors to try to hassle them with useless anti-trust laws.
My reading of generosity of "robber barons" is that they considered themselves very lucky, were sitting on a ton of cash, and wanted to do something beneficial to society with that money.
At the same time, many also wanted to have lasting monuments to themselves because they were megalomaniacs. But the truth is that many CEOs tend to be that way. If you believe in yourself enough, other people tend to follow you. That's one of the reasons you pay multinational CEOs so much is because it takes a rare person crazy/megalomaniacal enough while also being reasonably intelligent and socially capable to get tends of thousands of people to take orders from you. And also if you are rich, people tend to kowtow to you as well. It is a bit like...government! Only instead of voting them out of office, you can choose not to buy from them if you don't like the product.