Solar electricity generation works by converting energy from the sun, in the form of light, into electricity. Solar cells are made of semiconductors and work via what is known as the photovoltaic (PV) effect. In this process when light hits a conductor and semiconductor it transfers its energy to that conductor.
Light is actually a stream of energy particles called photons. When the photons hit the silicon surface in the solar cells they generate electricity by transferring energy and freeing electrons. In this way electricity is generated. Put simply, photovoltaic cells are energy converters converting the energy from sunlight into electricity.