Cerebrospinal fluid (CSF) serves two main purposes; it acts as a shock absorber to prevent damage to the brain and spinal cord, and (much more interestingly) because it entirely surrounds the brain, it reduces the pressure that the top bits place on the bottom bits, in effect preventing your brain from being squished under its own weight.
The CSF can be found in between the two innermost meninges (the arachnoid membrane and the pia mater) in an area called the subarachnoid space, and filling the ventricles in the brain. CSF is manufactured continuously, and the entire volume (about 125 mL) is replaced every three hours. Similar in chemical makeup to blood plasma, CSF is actually derived from the blood by the choroid plexus, a bit of tissue with a rich blood supply that sticks into all of the ventricles. After circulating from the ventricles into the subarachnoid space, old CSF is reabsorbed through little pouchlike protrusions called arachnoid granulations. From these it moves into the the blood vessels that drain the brain.
The best way to keep the CSF in good shape is by doing all the things that keep your blood in good shape. Most importantly, drink plenty of fluids. Insufficent CSF, or any blockage of the flow of CSF out of the subarachnoid space could result in permanent or even fatal brain damage, in the former case by squishing, in the latter by blocking the flow of blood into the brain.
main source: Physiology of Behavior, 6th edition, 1998. Neil R. Carlson