The theoretical basis for thermometers is the zeroth law of thermodynamics which postulates that if you have three bodies, A, B and C, if A and B are at the same temperature, and B and C are at the same temperature then A and C are at the same temperature. B, of course, is the thermometer.