when a person has diabetis why do they cut off their leg?

i know that they dont cut them off in all cases, but when they do why do they do it. Ive always wanted to know.