What causes bad kidney functioning?

Lots of things. Hypertension, medication, age, trauma, auto immune diseases and many other things. If you are having an issue with your kidneys, then it's time to call your family doctor.
Many things. The most common conditions that damage kidneys are diabetes and hypertension, but others can as well. Some hormone problems affect them, blood vessel blockages such as renal artery stenosis, drugs, medications both prescription and over the counter. Some inherited or congenital diseases can lead to kidney damage as well.