The original energy that caused the rotation of the Earth when it was formed came from the gravitational collapse of the cloud of dust and gas that formed the solar system. Maintaining rotation at constant speed in a vacuum does not require any further input of energy. Conservation of angular momentum keeps the Earth rotating. In fact, over long time scales (millions of years) the Earth’s rotation does slow down gradually due to energy lost in friction and tidal forces.