I don't have any publication at hand, but I think it's a problem of balance between energy use and saving water. Ammonia is toxic, as mentioned by Anil, and it requires much water to remove from organism so it's produced primarily by water organisms which are not constraint by lack of water. Urea is less toxic and requires less water to remove from organism (so it's better in terrestrial environment) but it requires more energy to produce. And uric acid is most costly in terms of energy but requires the least amount of water to remove. Therefore animals producing uric acid lose a little water with it.
Urea is more water soluble than uric acid (Almost insoluble substance). Urea is also more toxic. Both however are less toxic than ammonia. Urea is a product of the degradation of amino acids. In the process amino acids lose their amine group which is then transformed into ammonia. In the liver ammonia reacts with carbon dioxide to form urea and water, a process called ureogenesis.
I don't have any publication at hand, but I think it's a problem of balance between energy use and saving water. Ammonia is toxic, as mentioned by Anil, and it requires much water to remove from organism so it's produced primarily by water organisms which are not constraint by lack of water. Urea is less toxic and requires less water to remove from organism (so it's better in terrestrial environment) but it requires more energy to produce. And uric acid is most costly in terms of energy but requires the least amount of water to remove. Therefore animals producing uric acid lose a little water with it.
I understand most mammals excrete allantoin instead of uric acid, but we humans have lost the gene to do so. This may not necessarily be an adaptive trait.
Uric acid is a very powerful antioxidant and reducing substance that may substitute for ascorbate in higher primates, birds, and many reptiles. Arguably, the longevity for size in such species is at least partially a consequence of urate's antioxidant properties.
Urate accounts for over half the antioxidant potential of human blood. Currently, there are human trials involving raising uric acid levels to treat stroke and Parkinson's disease.
Urate's insolubility means that it requires little water to eliminate-- Its the white stuff in birdsh!t. But at the same time, it means that uric acid readily precipitates out. Thus, gout and urate kidney stones. Better just to use urea, which is very soluble in water.