Lenders adjust mortgage rates depending on how risky they judge the loan to be. A riskier loan has a higher interest rate.
When judging risk, the lender considers how likely you are to fall behind on payments (or stop making payments altogether) and how much money the lender could lose if the loan goes bad. The major factors are credit score and loan-to-value ratio.
The lowest mortgage rates go to borrowers with credit scores of 740 or higher. These borrowers have the broadest choice of loan products.