Only a part of the interest comes from risk.
One important part is that if I were to give you 10$ in 10 years, it has less value to you than me giving you 10$ now (which is the difference between lending you lending to me and you not lending to me if you were 100% sure I would pay back).