The thermoelectric effect was discovered by Thomas Seebeck.
The reverse is also possible, whereby a voltage across two different materials creates a difference in temperature. This is the Peltier effect.
Electrons flow from the hot end to the cold end.
Different materials will create different voltage potentials.
Thus, a thermocouple works by measuring the difference in potential caused by the dissimilar wires.