How come socialism becomes the answer to everything in The Jungle?
From Upton Sinclair's point of view, it was. He was a strong supporter of socialism, as the time he lived in, the Gilded Age, let robber barons and business leaders do whatever they wanted to the working man in the name of increased profits. To Sinclair, the robber barons themselves were not evil, but profit made them act that way. Remove profit and give people economic equality, and he believed that most of the social and economic ills of the time would disappear.
Of course, socialism as an economic system has serious problems, and purely socialist societies have mostly been failures, but in a world without a single socialist economy in 1906 when The Jungle was published, Sinclair could not have known that. The book itself was meant to shock the country into believing that socialism was the solution. Few received that message. Instead, government just cleaned up the meatpacking industry.
The previous post is extremely accurate. In a setting where uncontrolled wealth acquisition and the rise of the Robber Barons dominated the social, political, and economic landscape, Progressivists like Sinclair believed that only a zealous advocacy of socialism and Marxist ideas could help offset the perils of excessive and unregulated capitalist ideology. Progressivists felt that the needs for consumer protection, worker's rights, equitable compensation, as well as a more humanistic approach to individuals who come to America could only be addressed through Socialism. Sinclair's embrace of Socialism is more of a response to Social Darwinistic beliefs of laissez faire.
If you are just looking at the specifics of the book, socialism becomes the answer to everything because it seems that all of the bad things that happen to Jurgis and his family are caused by inequality -- inequality of money and power.
Every time something bad happens to Jurgis or a family member, it is done by a rich person or the representatives of the rich. In socialism, there are no rich. Everyone is equal and no one can use their money to abuse those with less money.
Seeing this, you can see why Jurgis would be attracted to socialism.