Credit history is used to asses what kind of risk you are, and if an entity decides to loan you money.
If you own many credit cards and a mortgage, and never missed a payment, companies will be happy to give you more credit, because you proved that you manage, and pay back your debts on time.
If you have a negative mark, missed mortgage payment or missed credit card payment, companies will tend to reject credit because you pose a higher risk that you have financial problems.
They can also see how many times you had credit searches done, the more searches you that are done against you also increases the risk factor, because it means you might be applying for several loans at the same time to cover other debts.
If you file for bankruptcy, you can wipe your hands clear of debt, but this causes big costs for companies who will fight to claim ownership on assets you owned, so they they repay your loan and pay of legal costs. Basically, they want to avoid this because they want to make money from you easier instead of going into long and costly legal battles.
After bankruptcy you are, basically stuffed. Getting a loan of any kind is almost impossible.