It seems that a nuclear thermoelectric generator was used to power spacecrafts for some exploration missions. Can a thermopile that harvest the light/shade temperature difference on Earth's orbit be used to power a small satellite? What about a Mercury satellite, would it be more reliable and efficient than solar panels which could melt on those conditions?
There's no theoretical reason why not. The main reason why they aren't used is practical: the best solar panels convert about 22% of available energy to electricity, while the best thermoelectric generators operate at about 8% of Carnot efficiency, which for a reasonable temperature gradient works out to converting about 4% of available energy.