The thermoelectric effect or Seebeck effect is the voltage created from one end of a conductor to the other when one end is a different temperature then the other.

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.