Before they decide on the terms of your mortgage loan (which they base on their risk), lenders need to know two things about you: whether you can pay back the loan, and if you will pay it back. To figure out your ability to pay back the loan, lenders assess your debt-to-income ratio. To assess your willingness to repay, they use your credit score.
Fair Isaac and Company built the first FICO score to help lenders assess creditworthines. You can find out more on FICO here.
Credit scores only take into account the info in your credit profile. They don't consider income or personal characteristics. These scores were invented specifically for this reason. "Profiling" was as bad a word when FICO scores were invented as it is in the present day. Credit scoring was envisioned as a way to assess willingness to pay while specifically excluding other demographic factors.
Past delinquencies, derogatory payment behavior, current debt level, length of credit history, types of credit and the number of inquiries are all calculated into credit scores. Your score is calculated wtih both positive and negative items in your credit report. Late payments count against your score, but a record of paying on time will improve it.
To get a credit score, borrowers must have an active credit account with at least six months of payment history. This payment history ensures that there is enough information in your credit to assign an accurate score. If you don't meet the minimum criteria for getting a score, you may need to work on your credit history before you apply for a mortgage loan.