Lubos' answer already here is very good. Just explaining something...
There are terms like Ionization energy, Electron affinity and Electronegativity (mostly used in chemistry) both describe the love for the atoms towards the electrons. The two former ones denote the energy involved while the latter one denotes the ability for transferring electrons.
It's good to say that this "charging by rubbing" effect is a surface phenomenon. Let's consider that you rub a material at one part of the triboelectric electric series with a material at another part. During this friction, the surface atoms of both the materials are pressed together bringing the electron clouds to a closer proximity thereby causing an interaction, which results in the transfer of electrons among the clouds. There are various possibilities for such transferring of electrons (perhaps, not required here)...
It should be noted that these transferred electrons are not so stable. Once they get some contact (like touching), the atoms readily lose these electrons (in accordance with the series) because the ionized ones act in a way on how to "lose their extra electrons or gain deficient electrons" under normal conditions.
Response to your comment:
Air is very likely to lose electrons. Does this mean the matters around us are constantly gaining electrons? Why can't we feel it when we are touching the matter?
Indeed, air is likely to get ionized. The triboelectric series specifically says that materials of the same kind (or those nearer to each other) don't transfer charges when rubbed with each other. Unless you provide a constant supply of electric field (to break its potential barrier), air doesn't have to get ionized. If it does, we can feel the charges like : "Hairs getting up" like that...