A lumbar puncture is primarily performed for diagnostic purposes. It helps in diagnosing conditions such as meningitis, multiple sclerosis, and subarachnoid hemorrhage. It can also be used to measure CSF pressure or to administer medications directly into the CSF, such as in the treatment of certain cancers or infections.