I hope someone finds this interesting/useful. It's about half copy/pasted from Wikipedia and half original:
Contact induced charge separation
Materials are made of atoms that are normally electrically neutral because they contain equal numbers of positive charges (protons in their nuclei) and negative charges (electrons in "shells" surrounding the nucleus). Electrons can be exchanged between materials on contact; materials with weakly bound electrons tend to lose them, while materials with sparsely filled outer shells tend to gain them. Upon separation, they retain this charge imbalance. This is known as the triboelectric effect and results in one material becoming positively charged and the other negatively charged. The triboelectric effect is the main cause of static electricity as observed in everyday life, and in common high-school science demonstrations involving rubbing different materials together (e.g., fur against an acrylic rod). Contact-induced charge separation causes your hair to stand up and causes "static cling" (for example, a balloon rubbed against the hair becomes negatively charged; when near a wall, the charged balloon is attracted to positively charged particles in the wall, and can "cling" to it, appearing to be suspended against gravity).
The polarity and strength of the charge on a material once they are separated depends on their relative positions in the triboelectric series. A material towards the bottom of the series, when touched to a material near the top of the series, will attain a more negative charge, and vice versa. The further away two materials are from each other on the series, the greater the charge transferred. Materials near to each other on the series may not exchange any charge, or may exchange the opposite of what is implied by the list. This depends more on the presence of rubbing, the presence of contaminants or oxides, or upon properties other than on the type of material. Lists vary somewhat as to the exact order of some materials, since the charge also varies for nearby materials.
During separation, some of the charge flows back reducing the amount of static electricity. The amount of backflow depends on the degree to which both materials are conductors. If both materials are strong conductors, the amount of backflow will be great and very little static electricity will be generated. Conversely, for significant static electricity to be generated, at least one of the materials must have a high resistance to the flow of electrons (be an insulator). The amount of charge backflow also depends on the speed of separation: slower speed equals more backflow.
Static electricity from coffee grinding
In coffee grinding, we have two materials, coffee beans and steel. Unfortunately I can't find a triboelectric series with coffee beans in the list. For the purpose of this discussion, I'll assume that coffee beans lie further up the list (more positive) than the steel of the burrs. In this case the grinds will take on a positive charge (i.e. they will be stripped of electrons) and the burrs will take on a negative charge. If the burrs are grounded, the extra electrons will flow to ground and the burrs will remain nuetral, but the positive charge will remain on the grinds. As noted above, at least one of the materials must be an insulator for static electricity to be generated. This is why humidity matters. The conductivity of coffee grinds increases as the water content of the beans increases. Spraying water on the beans helps increase conductivity and therefore reduces static. The speed of separation also affects the amount of charge backflow. Slower grinding results in less static.
Induced charge (static cling)
When a charged object is brought near an uncharged, electrically conducting object, such as a piece of metal, the force of the nearby charge causes a separation of positively charges nuclei and negatively charged electrons. For example, if a positive charge is brought near a metal object, the electrons in the metal will be attracted toward it and move to the side of the object facing it. When the electrons move out of an area, they leave an unbalanced positive charge due to the nuclei. This results in a region of negative charge on the object nearest to the external charge, and a region of positive charge on the part away from it. These are called induced charges. If the external charge is negative, the polarity of the charged regions will be reversed. The overall charge of the metal object has not changed, but because the attraction between positive and negative charges falls off quickly with distance, the force of attraction between the charged particle and the near region of the metal object is stronger than the repellant force between the charged particle and the far part of the metal object. The net result is that the charged particle is attracted to the uncharged metal object.
A similar induction effect occurs in nonconductive (dielectric) objects, and is responsible for the attraction of small light nonconductive objects, like scraps of paper or Styrofoam, to static electric charges. In nonconductors, the electrons are bound to atoms or molecules and are not free to move about the object as in conductors; however they can move a little within the molecules.
If a positive charge is brought near a nonconductive object, the electrons in each molecule are attracted toward it, and move to the side of the molecule facing the charge, while the positive nuclei are repelled and move slightly to the opposite side of the molecule. Since the negative charges are now closer to the external charge than the positive charges, their attraction is greater than the repulsion of the positive charges, resulting in a small net attraction of the molecule toward the charge. This is called polarization, and the polarized molecules are called dipoles. This effect is microscopic, but since there are so many molecules, it adds up to enough force to move a light object like a coffee grind.
Managing static electricity in a coffee grinder
In order to reduce static electricity in the coffee grinds, we need to replace the electrons that the have been stripped from the grinds. This can be done in two ways. First, by grounding any metal surfaces that the grinds come in contact with (in the grinder and in the portafilter). Second, by implementing an electrically conducting path between the burrs, which have absorbed the electrons that have been stripped from the grinds, and the metal surfaces that the grinds come in contact with. Painting or otherwise insulating the metal surfaces that the grinds come in contact with will remove any possibility of neutralizing the static charge that built up during grinding.
Now, if you have followed what I've written and are a critical thinker, you should be saying: "but wait a second, isn't encouraging more contact with metal and subsequent separation going to generate more static rather than less?" The answer to that is yes and no. Yes, there will be more separation induced charge, but because the speed of separation is much slower than in the burrs and because the grinds are already positively charged and the metal is negatively charged (assuming a conductive path to the burrs), the charge backflow will dominate the charge induction and static on net will be reduced.