Any liquid that expands in the heat and contracts in the cold would work, and you could use any of them inside a thermometer.
The problem is finding a liquid that has a good workable range between its freezing and boiling points.
Water, for example, has a freezing point of 32 °F (0 °C) and a boiling point of 212 °F (100 °C), making it unsuitable for measuring temperatures that are hotter or colder than that.
Mercury is more suitable for temperature extremes because its freezing point is -38 °F, and its boiling point is 675 °F. Its silvery color is also an advantage in that it’s highly visible.
Incidentally, the man who first used mercury in thermometers was G. D. Fahrenheit (1686-1736), the man who also invented the Fahrenheit scale. Before that, alcohol was the liquid of choice.
Nowadays, because of mercury’s dangers, many thermometer manufacturers have gone back to alcohol, which freezes at -175 °F (-115 °C).
Alcohol is not as good at higher temperatures, since it boils at 173 °F (78 °C), but for most household purposes that’s hot enough.