Urine production is complicated and would take several lessons to describe.
Basically, the body uses fluids to make many physical and chemical functions work properly. These are all regulated by feedback mechanisms. For example, the small intestines pulls fluid into the intestines during part of the digestive process. Then, those fluids are pulled back out. (If too much fluid is pulled out, it can result in constipation.) The blood picks up excess fluid which is also pulled out by the kidneys. This, and other processes, are controlled in a delicate "fluid balance" dance that is controlled mostly by the brain and hormones. The kidneys (2 of them) is the last stage of filtration of fluid from your body. The kidneys "pull off" excess fluid gathered from the blood as well as returned from the intestines. If there is heart disease, the heart may be unable to handle excess fluid loads and the same for the kidneys.
The kidneys make the urine almost completely sterile, unless the body has infection or disease (such as diabetes). The urinary bladder stores the urine from fluids processed by the kidneys. Interestingly, the brain does NOT tell the body "don 't urinate"-- as far as the brain 's normal impulses, the bladder could release the urine anytime. But, when the brain finally turns OFF the "go anytime" switch, it is THEN and only then that we have the urge to urinate. (So the nerve mechanism is backwards: the "go" signal is always "on"; when the "go" signal is "off", then we want to urinate.) At the same time, the brain is receiving feedback about bladder fullness and pressure. When you feel enough pressure to need to urinate, the brain has turned off the "go anytime" switch...and then, you relieve yourself.