Why two objects get charged by rubbing?
The effect in which two objects get charged by rubbing and remain charged is called the triboelectric effect ,
where the root "tribo" means friction in Greek (The Greek word $\tau\rho\iota\beta\omega$ means 'to rub'). Friction is actually unnecessary: contact is enough in principle.
This effect shouldn't be confused with the (Volta or Galvani) "contact potential" between metals which only exists as long as the two metals remain in contact, and especially not with "contact electrification" which was a name of a scientifically incorrect theory of electricity at the end of the 18th century that attempted to overgeneralize the interpretation of the triboelectric effect. "Electrophorus" was a gadget, first produced by Volta, that used the triboelectric effect.
The cause of the triboelectric effect is adhesion - the atoms on the surface literally form chemical bonds. Materials such as fur are ready to lose electrons and become
positively charged while the materials such as ebonite or glass gain electrons and become negatively neutral. To get some idea about which atoms are likely to lose or gain electrons, it's useful to know their electronegativity:
The redder atom, the higher electronegativity, and the more likely it is for the atom to gain electrons and become negatively charged. That's especially true for light halogens (fluorine, chlorine) and oxygen. That's partly why glass - with lots of $SiO_2$ - likes to get negatively charged in the triboelectric effect. Even sulfur (40% of ebonite) has a higher electronegativity than e.g. carbon and hydrogen that are abundant in the fur which is why fur loses electrons and becomes positively charged.
Of course, the actual arrangement of the atoms in the molecules matters, too. So this overview of the periodic table was just an analogy, not a reliable way to find out the results of the triboelectric effect.