There are several possible ideas. First, when the planets were originally accreting themselves out of the material in the rotating proto-planetary disk orbiting the infant Sun, material slightly further out from the Sun moved slower than material accreted from locations slightly closer to the Sun than the Earth's orbit. This net velocity difference caused the Earth to accrete material with a net angular momentum. The Earth, essentially, absorbed material that was in a state of rotation itself. Another possibility is that when Earth was suffering impacts by large bodies towards the end of its formation phase, some of these impacts, or perhaps only one real large one, occurred off center so that the collision itself caused the Earth to spin. A similar scenario has been frequently advocated to explain why the rotation axis of Venus and Uranus are so out of whack compared to the other planets. The rotation periods for the planets range from 10 hours for Jupiter, to 58.6 days for Mercury, so even for the 'normal' planets there is quite a range of possibilities, and no doubt quite a range of circumstances that led to their periods being what they are.