The level of risk in investments is taken into consideration. This is why very volatile investments like shares and junk bonds have higher returns than safer ones like government bonds.
The extra interest charged on a risky investment is the risk premium. The required risk premium is dependent on the risk preferences of the lender.
If an investment is 50% likely to go bankrupt, a risk neutral|risk-neutral lender will require their returns to double. So for an investment normally returning $100 they would require $200 back. A risk-averse lender would require more than $200 back and a risk-loving lender less than $200. Evidence suggests that most lenders are in fact risk-averse.
Generally speaking a longer-term investment carries a maturity risk premium, because long-term loans are exposed to more risk of default during their duration.