Before they decide on the terms of your mortgage loan, lenders must know two things about you: your ability to repay the loan, and if you are willing to pay it back. To understand your ability to pay back the loan, they look at your income and debt ratio. To assess how willing you are to repay, they use your credit score.
Fair Isaac and Company developed the original FICO score to help lenders assess creditworthines. You can learn more about FICO here.
Credit scores only consider the info contained in your credit reports. They don't consider income or personal characteristics. These scores were invented specifically for this reason. "Profiling" was as dirty a word when these scores were first invented as it is today. Credit scoring was invented as a way to consider only that which was relevant to a borrower's likelihood to repay a loan.
Your current debt level, past late payments, length of your credit history, and a few other factors are considered. Your score considers positive and negative items in your credit report. Late payments count against you, but a consistent record of paying on time will improve it.
To get a credit score, you must have an active credit account with six months of payment history. This history ensures that there is enough information in your report to generate a score. Some people don't have a long enough credit history to get a credit score. They may need to spend some time building up a credit history before they apply.