Earth spins because of the way it was formed. Our solar system formed about 4.6 billion years ago when a huge cloud of gas and dust started to collapse under its own gravity. As the cloud collapsed, it started to spin. Some of the material within this cloud gathered into swirling eddies and eventually formed into planets. As the planets formed they kept this spinning motion. This is similar to what you see when skaters pull in their arms and spin fasterie, comes the angular momentum concept. As material gathered in more closely to form a planet, like Earth, the material spun faster. The Earth keeps on spinning because there are no forces acting to stop it.
similarly the same intrinsic property is applicable for electrons also.it is still under research.