The textbook answer is that animals need to urinate in order to excrete extra salts and nitrogen metabolites from their blood. The ammonia in aquatic animals, insoluble uric acid in birds, diapsid reptiles, and insects, and soluble urea in amphibians and mammals are the means of disposing the N generated by transdeamination of unwanted amino acids. Terrestrial animals stay away from the ammonia as it takes a lot of water to dilute it to reduce toxicity. The familiar yellow color of urine is from a product of heme breakdown, urobilin, which is a minor component. This sounds reasonable, but urination is a deep mystery. The mystery is twofold: the physiology of peeing and the biochemistry of urea metabolism. The more one thinks about these matters, the stranger it looks. A visit to a restroom can and should be food for thought.
If the goal of peeing is disposing of waste, then having a separate urinary tract seems unnecessary. Most of animals do not have it. The vent in birds, the Malpighian tubules in insects, and the cloaca in reptiles, amphibians, marsupials, and monotremes combine all of the excretionary functions in one neat unit, and it works just fine. The turtles can even respire through their cloaca! It is not too obvious why the separate urinary tract exists in placental mammals and bony fish, and no other animal.
It makes even less sense, from the standpoint of waste management, to store the toxic waste in a bladder. Birds do not have a bladder and do very well without it. In mammals, the bladder seems to have little other use than storing urine for the purpose of marking territory. It goes without saying that one can find other ways of marking territory.
In our amphibian ancestors, the bladder was used to conserve fluids: when in water, the frog’s bladder rapidly fills up with urine. This water is reabsorbed into blood on dry land, to replace water that is lost by evaporation. Already in reptiles this function of the bladder has been lost. As the mammals branched off the reptile tree before the latter developed their efficient uric acid excretion (which requires very little water), we still possess the primitive and inefficient urea excretion metabolism of the amphibians. Actually, our (amphibian) way of producing the urea from ammonium and bicarbonate ions, by ornitine-urea cycle, is used by only one other living animal, the coelacanth. Most other vertebrate and invertebrate species make the urea from uric acid that is formed from purines, which is a much better way of disposing N. Biochemically, we are living fossils. We can make uric acid, but we do not rely on it. Some people can make more of it; those unlucky few develop gout.
The need of disposing of the ammonia is understandable, in view of its high toxicity, but the production of urea is not. The common way of disposing NH3 in Nature is converting it to nitrate (by aerobic nitrifying/NH3-oxidizing bacteria) which is converted to N2 by anaerobic denitrifying bacteria or directly converting it to N2 (by anaerobic anammox bacteria); there is a global operation of this sort by marine prokaryotes. Actually, most of the N2 we breathe has been made by the anammox bacteria. Getting rid of the gaseous N2 seems to be a much easier solution than production of urea and/or uric acid and the trouble of their disposal. Furthermore, the ammonia can be excreted by volatilization, and this is the main way of N excretion in snails, crabs, and isopods. The fish also flash most of their ammonia through their gills rather than kidneys; the latter serve mainly for regulation of the osmotic pressure. Livelock made a big deal out of urea/uric acid excretion by land animals: he made an elaborate argument that in this way N returns in a fixed form ready to be reabsorbed by plants. The urination proves that animals and plants form a harmonious union: peeing is ecologically responsible way of returning the surplus of N, as opposed to N2 evolution, which would be selfish and irresponsible. That may be so, but the bacteria do the “irresponsible” thing anyway, and animal urination has almost no effect on the global turnout of fixed N. I seriously doubt that we pee to restore harmony to Nature. Some ruminants, actually, behave rather “irresponsibly”: they convert ammonia to urea and leak the urea to their rumen, where it is degraded back to ammonia by symbiotic bacteria. This ammonia supports protein synthesis in these bacteria and also serves as the feed for nitrifiers present in the gut.
Furthermore, one may ask, how is it that we (the animals) need to get rid of N which is such a precious commodity? The problem is a major defect in our design: we can store the excess carbohydrates and lipids, but – unlike the plants - we cannot store the excess amino acids. So any excess of the latter has to be catabolysed to ammonia and/or glutamate. This is tremendous waste of a good thing, and the lack of such storing mechanism is evolutionary scandal. An idea that I have about this puzzling deficiency is that it would be very useful to symbiotic phototrophs, such as the zooxantellae in corals, as this inexplicable deficiency is precisely what forms the basis of mutualistic trade (N fertilizer exchanged for carbohydrates). If the animals began as symbionts with algae, as I argued elsewhere, the selfish storage of amino acids and/or the excretion of N2 would be penalized by their photosymbionts, so it is possible that we were forced
to urinate by the selective pressure of such symbiosys. What Lovelock considers to be holistic unity of land animals and plants could be the consequence of mandatory co-operation between the proto-animals and their photosymbionts. Such symbiosys was the only realistic chance to survive the long periods of anoxia at the end of the Cryogenian. Perhaps we are peeing because such was our function back then, 600-700 Mya…
Said that, there are marine invertebrate animals that accumulate amino acids (glycine, alanine) in their intracellular compartments, although these amino acids are accumulated exclusively to… counterbalance the osmotic pressure of sea water (i.e., our core deficiency is still there). It turns out that our distant cousin the coelacanth uses the urea for the same purpose. So it appears that the urea metabolism originally served a different purpose than peeing: the osmoregulation. Then in some lobed fish that happened to be our ancestors it became also a way of ammonia disposal; though, it was not really a disposal, as they actually needed the urea. The amphibians that descended from these fish inherited their urea metabolism, although they had absolutely no need for osmoregulation. They compensated for the inherent deficiency of the urea excretion by using bladders for water retention. We inherited both this inferior metabolism and the useless organ from our dry land dwelling reptilian ancestors. As the rest of the tetrapods switched to a better way of dealing with the N waste, the mammals stubbornly stuck to the antique practice of urea peeing. At some point they began using pee for marking and signaling, and that transformed peeing into an art form. Having a full bladder of dilute urea solution became the necessity of social life.
Why do we pee?
PS: Further reading: http://jeb.biologists.org/cgi/reprint/198/2/273.pdf