A donated kidney may come from an anonymous donor who has recently died or from a living person, usually a relative. The kidney must be a good match for the patient's body. The more the new kidney is like the person receiving the kidney, the less likely the immune system is to reject it.
The immune system protects a person from disease by attacking anything that is not recognized as a normal part of the body. So the immune system will attack a kidney that appears too "foreign." The patient will take special drugs to help trick the immune system so it does not reject the transplanted kidney.
Unless they are causing infection or high blood pressure, the diseased kidneys are left in place. Kidneys from living, related donors appear to be the best match for success, but kidneys from unrelated people also have a long survival rate. Patients approaching kidney failure should ask their doctor early about starting the process to receive a kidney transplant.