Whereas the Earth is kept in its orbit around the Sun by the attractive gravitational force between them, the electrons are kept in the atoms by the electrical force that attracts them to the protons (electrons have negative charge, protons have positive charge, and opposite charges attract).