Gram staining is a method for identifying different classes of bacteria. Originally developed to make bacteria easier to view in a blood culture, it was discovered that some bacteria reacted one way to the stain and others reacted in a different way.
If a bacteria has a thick cell wall, it absorbs the dye used in the procedure very well and will take on a distinct purple color. However, if it has a thin cell wall, it undergoes a different chemical process and turns pink. In medicine and infectiology, one that turns purple is called "gram positive" and ones that do not are called "gram negative".
As antibiotics have a mechanism of action, some antibiotics will not work on gram negative bacteria. For example, penicillin works by preventing the formation of a new cell wall, so only works on gram positive bacteria. Others, such as streptomycin, will work on either type, but have more severe side effects.
Gram staining is a common procedure when infection is suspected and must be identified to use as narrow a spectrum antibiotic as possible. It can be used on many types of samples, including cerebrospinal fluid from a lumbar puncture. However, it is not infallible as not all bacteria clearly fall into these categories. However, it can still be an important diagnostic tool.