In 17th and 18th Century England, if you failed to pay your debts, you could be thrown in jail. To make matters worse, you were expected to pay for your food and clothes in jail. Thus, debtor's prison was often a death sentence: a particularly cruel and drawn out death by exposure and starvation. While this supposedly served as a deterrent, and gave creditors some emotional satisfaction, it did not repay the debt, and took a man out of the labor force.
This was of little concern in early industrial England, but out in the colonies, labor was too valuable to waste by imprisoning workers. It became important to devise practical schemes for debtors to "work off" their debt (indentured servitude). The colonies also instituted minimal bankruptcy protections, to allow debtors to keep their liberty and the bare means (shelter, clothing, tools and so forth) necessary to remain gainfully employed.
Gradually, at the edges of European conquest and development, there emerged a consciousness that economic activity involves risk. Businesses fail, even gold mines don't always "pan out". The more lenient attitudes in the colonies would itself encourage immigration, where in addition to being judicially deported to America or Australia, people would simply flee to the colonies to avoid creditors and the terrible spectre of debtors' prison.
In the United States, the solution to bankruptcy was to flee westward, to wherever the frontier happened to be. First, "gone to Kentucky", then "gone to Texas" and finally "lit out for the Territories" became synonomous with insolvency.
The gradual development of bankruptcy law can be seen by comparing the Constitutions of the early States with the later, Western states. The original colonies and the federal Constitution did not prohibit imprisonment for debt, indentured servitude, or slavery. In Western states and territories settled after the Civil War, State constitutions flat out prohibit imprisonment for debt. (Perhaps similar developments can be observed by comparing English law, and the laws of the West Indies, with 19th century Tasmanian or Australian law.) This took time: at the federal level in the United States, there was no permanent bankruptcy statute until 1898: about the time that the United States ceased to have a wilderness "frontier".
The New Mexico constitution, drafted in 1911, contains a typical provision outlawing debtors' prison: "No person shall be imprisoned for debt in any civil action.". N.M. Const. , Art. II, § 21. (Making it a constitutional provision makes it much harder for the law to be changed. There are no such protections at the federal level, and technically all it would take is an act of Congress to bring back debtors' prisons).
Note the limitation to civil actions. You can still be jailed for failure to pay fines imposed to punish criminal activity, and for contempt of court. Contempt, civil or criminal, however, requires proof of willful intent: you have the money but refuse to pay. Inability to pay is a defense, and just being poor is not a crime.