They have various methods. One of the common ones is analyzing ice core samples. The ice sheets are accumulated over the years so each layer on ice sheets is from a certain historical period (much like tree trunks.) By analyzing the chemical status of the ice core on each layer, they can extract data, such as temperature, about a certain period.