The main function of the kidneys is to filter harmful chemicals known as toxins from the blood. The toxins leave the body in the urine.