Friction produces static electricity by initiating the transfer of electrons between two or more objects. With regards to electron transfers, objects are either conductors or insulators. Conductors give up electrons readily because the electrons are not confined to a particular atom. Insulators do not transfer electrons readily.
When the right kinds of objects experience friction, the object that has a greater affinity for electrons takes some from the other object, which causes a charge imbalance. One of the objects now has fewer electrons and is positively-charged, whereas the other object has excess electrons and is now negatively-charged. The act of rubbing, which results in friction, is required for the transfer.