The sun's light (and all light) contains energy. Usually, when light hits an object the energy turns into heat, like the warmth you feel while sitting in the sun. But when light hits certain materials the energy turns into an electrical current instead, which we can then harness for power.
Old-school solar technology uses large crystals made out of silicon, which produces an electrical current when struck by light. Silicon can do this because the electrons in the crystal get up and move when exposed to light instead of just jiggling in place to make heat. The silicon turns a good portion of light energy into electricity, but it is expensive because big crystals are hard to grow.Newer materials use smaller, cheaper crystals, such as copper-indium-gallium-selenide, that can be shaped into flexible films. This "thin-film" solar technology, however, is not as good as silicon at turning light into electricity.This is an on going problem of making the solar panels cost efficient .