It is always more favorable for standards of living to specialize in areas of comparative advantage. Doing so generates higher incomes than not doing so. With the higher incomes, people can save and invest to accumulate capital which makes them even more productive. With their greater wealth they then can save and invest even more.
Americans both exported agricultural and extractive industry goods and attracted capital investment from abroad at the same time. The capital investment was invested in lines of production that eventual integrated America’s economy into the world’s advanced capital structure.
To use an analogy, A family who owns a farm, but no capital equipment for mining on his land or building a blacksmith shop and tools would be better served in obtaining mining equipment and a blacksmith shop and tools by specializing in agricultural products and selling them to others in exchange for their capital investment in the mining equipment and the materials to construct a blacksmith shop and blacksmith tools than in abandoning farming and trying to produce the mining equipment, blacksmith materials, and blacksmith tools himself.