Terrestrial animals live in an extremely water-poor environment. You might never have thought of it in these terms, but compared to the fishes from which land vertebrates evolved, even denizens of the wettest jungles are forced onto short water rations. The kidney was adapted to this situation. At least 99% of the fluid that is run through an animal's kidneys daily is reabsorbed, as are glucose and other nutrients, as well as ions.
Marine fishes have to get rid of massive amounts of salt, taken in through their permeable gills; freshwater fishes have to get rid of vast quantities of water, taken in the same way. The kidney in fishes thus evolved as a way to do both of these things: excrete or retain ions (mainly sodium and potassium) and/or excess water.
Fish solve their ionic balance problems by producing copious amounts of dilute urine. A freshwater fish is urinating more or less constantly just to get rid of his water load and a marine one to dispose of excess salt. But mammals and birds need that water, and so they have evolved kidneys capable of producing urine that is more concentrated than their body fluids. Birds in particular produce a urine that is thick and gooey; it's the white part of their droppings.
But what about waste disposal? Fish get rid of nitrogenous waste (the product of removing amino groups from proteins) by converting it into ammonia and most of it is lost through the gills to the unlimited supply of water around the fish. Ammonia is very toxic (as every aquarium keeper knows) and will quickly build up to dangerous levels in small tanks. Mammals don't have the option of using ammonia as a major nitrogenous waste product. They'd quickly reach toxic levels if they attempted to dissolve ammonia in their blood, so mammals produce less toxic urea instead, by a different pathway. Urea can be dissolved in blood and later in urine in reasonably high amounts, so as the kidney disposes of excess ions, urea goes with it.
Birds are really water stressed, because their cooling mechanism depends entirely on evaporation of water. They need a lot of water, much more on a weight basis than mammals do. So they go one step further. Not able to use even urea as a nitrogenous waste product, birds produce instead the nearly insoluble product, uric acid. This is mixed with just enough water to make a thick slurry and excreted.