Your credit score is the culmination of years of managing your credit cards, spending history, and different accounts.
A high credit score is usually assigned to someone who is always on top of their credit card balances. Once you start missing monthly payments, your credit score will take a hit.
Lending institutions will often offer the lower interest loans to mortgage applicants with higher credit scores because these applicants are considered low risk that lenders compete to add into their loan portfolios.
Applicants with low credit scores will often not get the advertised mortgage rates because these applicants are considered high risk with a chance of default. Banks will charge high fees and interest rates to applicants with lower credit scores to take on the risk of defaults.