Creditworthiness: the first factor to impact interest rate is the borrower's credit, that is how much the lender can trust him. Before lending money, the bank will often (especially for long-term loans or bigger amounts) check the borrower's credit history. The more 'trustworthy' the borrower is, the lower interest he can negotiate.
Market: trust and creditworthiness also works for the economy as a whole. Different interest rates are set between banks when they lend each other, or when investors issue bonds. The interest will vary according to the law of supply and demand and the investors and banks' anticipations. It also depends on a major player: the central bank. Governments can impact short-term interest rates by lending, borrowing or issuing money.
Length of time: if you borrow money on 20 years to buy a property, for example, the interest will be different from a loan on one month, as the risk is different.
Underlying assets: if you borrow money to buy a house, the bank will ask you to have a right on your house in case you cannot pay back the loan: this is called a security.
Inflation: that is how much value money loses over time; it also impacts interest rate.