From The School of Biomedical Sciences Wiki
Urea is the common name for the compound carbamide, found in urine. It is the major biproduct when nitrogen is metabolised in mammals and amphibians, and is water soluble, which allows it to be dissolved and excreted via the urine. It is also at a neutral pH in solution, which allows for safe excretion.
Carbamide is usually formed as a result of the deamination of amino acids, producing ammonia, (NH3) which reacts with Carbon Dioxide (CO2) to for carbamide.
2NH3 + CO2 => (NH2)2CO
Ammonia is highly toxic and is therefore replaced with the less harmful carbamide in order to be transported via the blood from the site of formation in the liver to the kidneys for excretion.