Due to the fact that a mortgage loan is a long term debt, the Treasury bond market (debt issued by the federal government) is used as a benchmark for determining appropriate values of a mortgage loan.
The selling of mortgage loans to investors is referred to as the "secondary mortgage market". Mortgage loans are sold to these investors when a lender has loaned out all of its available funds. This secondary mortgage market must be competitive with similar investment markets in order to find investors.
Inflation is the primary factor that affects the Treasury bond markets and interest rate levels. Inflation also effects the value of investor's fixed return investments. Treasury bond investors do not like inflation because it diminishes the value of their fixed return investments.
The threat of inflation is subdued when the economy slows down. When inflation is lowered then investors become more comfortable investing in long term debt and the Treasury bond market rallies.
When the price of a Treasury bond moves higher on weak economic news an investor is forced to pay more for this investment.
When the bond moves higher the yield which is the return on investment to the investor declines. This decline causes the yield on all similar investments including mortgage loans sold in the secondary market to decline as well.
If a lender can sell mortgage loans at a lower interest rate to investors, the lender is likely to pass on these lower rates to you, the borrower.