The body gains water almost entirely through food and drink. Water is lost primarily by urination; perspiration, respiration, and defecation also remove lesser amounts of fluid from the body. Maintaining proper hydration is important to keep blood volume constant and to allow for the creation of urine to remove nitrogenous wastes.
When fluid levels drop, sensors in the ventricles of the brain cause the pituitary to secrete vasopressin (also known as ADH, or anti-diuretic hormone), which slows the kidneys and causes them to make more concentrated urine to conserve water.
Aldosterone, a hormone secreted by the adrenal glands, has a similar function, but is secreted in response to blood pressure in the chest and abdominal cavity. Under normal conditions it functions in parallel with the brain sensors, but has a much faster response time to large changes, so it is also important during sudden events like bleeding or large environmental temperature fluctuations.
The major mechanism for adding fluid to the body is thirst. The exact physiology of thirst is not well understood, but it's generally agreed that the same brain sensors that cause te secretion of vasopressin are responsible for creating the sensation of thirst when fluid volumes drop.