HSPs function primarily as molecular chaperones, assisting in the correct folding of proteins, preventing aggregation, and aiding in the refolding or degradation of damaged proteins. Under toxic stress, such as exposure to heavy metals or chemicals, cells upregulate HSP expression to counteract the damaging effects. This cellular stress response helps to mitigate the potential for cellular damage and death, highlighting the protective role of HSPs in toxicology.