Electricity is the motion of electrons in a wire. It's these moving electrons that allow light bulbs to produce light, fans to turn, microwaves to produce heat, ...
To get the electrons to move requires energy. Fortunately the sun supplies us with this energy by sending us energetic photons. It's these photons arriving from the sun and hitting our solar panels that cause electrons ultimately to move down a wire.
What happens when the photons hit the solar panels? As the next diagram shows, panels, like everything else, are made up of atoms and atoms contain electrons. When a photon hits an electron, the photon is absorbed by the electron. The photon's energy is also absorbed by the electron. Since this electron now has more energy, it breaks free from the atom.
But if that were all there was to it then we'd just have a bunch of loose electrons moving around randomly. Something has to organize them to get them to move in one direction down a wire. Doing that is a big part of the solar panel's job. The solar panel is made up of two layers of slightly different materials. Keeping the explanation simple, the result of the two layers is that these free electrons get pulled to one layer and away from the other layer, resulting in the electrons moving in one direction only.
If we then connect one end of a wire to one of the layers and the other end of the wire to the other layer, these electrons that have gotten their energy from the photons and that have been forced to move in one direction only, will now move along the wire. And if we go further and split the wire somewhere along its length and put an applicance there, one that works using moving electrons, then we will be powering that appliance (e.g. the fan in the following diagram.)
If you want to learn how an off-grid system works, starting from where the above leaves off, then click below.