Deep space is a cold, empty, and lonely place. This makes it difficult for exploratory missions to the outer planets of the solar system. Within the asteroid belt - and Jupiter too if you play your cards right - solar panels provide enough electricity to power your sensors, communications gear, and computers.
But out at Saturn, Uranus, Neptune, or old forsaken Pluto, sun power is hard to come by. For those missions, space agencies turn to nuclear power. Specifically, a lump of some radioactive element stuck at the end of a long tube. The element decays, generating heat. But how to turn that heat into electricity?
The answer comes in the form of the thermoelectric effect. If you have two different metals glued together and heat them up, one will warm up in a slightly different way than the other, depending on the atomic properties of their elements.
So you've got one metal with hustling and bustling electrons, and another with more quiet participants. Like a party at your neighbor's, eventually the crowds start to migrate, looking for room to move. And electrons on the move = electricity.