Solar cells (also known as photovoltaic cells or PV cells) are made of special materials called semiconductors. In the 1940's, Bell Labs discovered that when light strikes this material, an electron would get knocked lose, allowing it to flow freely in the material. An electric field within the material makes all of the electrons flow in one direction, thus creating an electric current. If metal wires are placed on either end of the PV cell, the current will be externally routed through a load. With enough PV cells and enough photons of light, you can power a calculator, an LED light or even household appliances.
When two silicon atoms are placed next to one another in a crystalline structure, they share 4 electrons amongst themselves. In a pure silicon crystal, this electron sharing is quite stable and the bonds are quite strong. Pure silicon is a non-conductive material since electrons cannot easily be removed from these bonds. It is electrically neutral. However, 'good' impurities can be mixed into the structure to make it behave differently.
Phosphorous is an element that can share up to 5 electrons with its neighbors. Since silicon only needs to share 4 electrons with its neighboring atoms, when phosphorous is added to the crystalline structure, there is one extra electron that will not strongly bond with its neighbors and will sort of 'float around'. The extra electron makes this doped material electrically negative and is called N-type (negative-type). That's half of the explanation.
Boron is an element that can share only 3 electrons with its neighbors. Since silicon needs to share 4 electrons with its neighboring atoms, when boron is added to the crystalline structure, there is a 'hole' created. One electron is needed to fill this hole but none are available in this silicon-boron solid. The material is electrically positive and is called P-type (positive-type). That's the other half of the explanation.
If we sandwich the two materials together, we'll have one side wanting an extra electron (P-type) while the other side can donate one extra electron (N-type). It's a match made in heaven, but only if we add some energy, such as sunlight. When photons strike the silicon-phosphorous solid, it has enough energy to 'kick' the extra electron out of the N-type material. If we put metal wires on either side of the sandwich, then these 'floating' electrons will start moving through the wire, through an external circuit (i.e. a light bulb or battery) and then to the P-type side of the sandwich. The moving electrons form an electric current also know as electricity.
You may ask why the electrons will travel though the external wires and not just cross the gap where the two sides of the sandwich meet. At this location, some of the extra electrons from the N-type side do hop over to fill the holes in the P-type side but not entirely. As more and more electrons make the hop, an electric field is created (a voltage). As this field strengthens, it makes it harder for the extra electrons to hop over the barrier. They find it easier to travel around the external circuit than try to overcome this strong electric field at the junction. As the electrons travel through the wire, it creates an electric current and we can now power our appliances & toys.
You might also wonder why a semiconductor is called a semiconductor. This N-type and P-type material is only conductive when energy (in this case, sunlight) is applied. Take away the energy -- for instance, after the sun has set for the day -- and it does not conduct electrons anymore. The material is only semi-conductive - in a semiconductor.