Extreme events provide relevant insights into the dynamics of climate and their understanding is key for mitigating the impact of climate variability and climate change. By applying large deviation theory to a state-of-the-art Earth system model, we define the climatology of persistent heatwaves and cold spells in key target geographical regions by estimating the rate functions for the surface temperature, and we assess the impact of increasing CO$_2$ concentration on such persistent anomalies. Hence, we can better quantify the increasing hazard {color{black}due} to heatwaves in a warmer climate. We show that two 2010 high impact events - summer Russian heatwave and winter Dzud in Mongolia - are associated with atmospheric patterns that are exceptional compared to the typical ones, but typical compared to the climatology of extremes. Their dynamics is encoded in the natural variability of the climate. Finally, we propose and test an approximate formula for the return times of large and persistent temperature fluctuations from easily accessible statistical properties.