For the sake of discussion, let’s assume that the globe is positively charged.
When the foil is near the globe, the globe’s electric field causes the electrons in the foil to shift, inducing negative and positive charges on opposite ends of the foil.
Thanks to the inverse-square nature of Coulomb’s forces, the electrical attraction acting on the negatively charged near end of the foil is stronger than the electrical repulsion acting on the positively charged far end of the foil. The foil thus accelerates towards the globe.
When the foil touches the globe, electrons are attracted into the globe, leaving the foil positively charged. The foil is thus quickly repelled away from the globe.
As the foil slowly loses its positive charges to the surrounding air molecules, the cycle repeats again.