If history is our guide, capitalism can not on its own always correct social problems. During the Gilded Age, capitalism was at its height, and it was largely unregulated and "laissez-faire" in nature. As a result, consumers and the society as a whole were at risk.
For example, the Food and Drug Act of 1906 was passed under Teddy Roosevelt's administration to protect the public from patent medicines that had no real value (or that were sometimes harmful) and from tainted food. The issue of tainted food became particularly apparent during what's generally referred to as the U.S. Army Beef Scandal, when, during the Spanish-American War, the Secretary of War (Russell A. Alger) bought tainted meat from the big-three meatpacking companies (Swift, Armour, and Morris) that caused soldiers in the U.S. Army to become sick and even die. This scandal, which weakened soldiers already combating malaria and other conditions, shed light on the need for greater government protection of consumers. Leaving consumers to regulate their own consumption of meat and allowing producers to regulate their own products was not working.
The problem with unregulated capitalism is that it does not always protect the weakest or most vulnerable members of society. In addition, a perfect capitalist system also relies on consumers having complete information about a product or service; however, as in the case of the U.S. Army Beef Scandal or the use of patent medicines that were harmful at worst and useless at best, it is impossible for consumers to have complete knowledge of some products. For example, consumers can't always know if meat is tainted or medicine has been proven useless or harmful. Therefore, the government has a role in safeguarding consumers and regulating the market so that producers cannot market harmful products and must meet some standards of honesty and effectiveness for their products and services.
In addition, correcting social problems does not always have a market incentive. For example, providing affordable housing does not in itself guarantee profits, or at least not the same kinds of profits that could be made by developers building luxury housing. Therefore, the government must intervene in the market to provide solutions that meet social needs, particularly those of the most vulnerable members of society. The Gilded Age also showed that when housing is unregulated, many people without means will live in unsafe and unsanitary housing conditions. Therefore, the government must intervene in these types of situations.