Threat Simulation Theory proposes that the function of dreaming is to simulate threatening events and scenarios, allowing the brain to practice threat perception and response. This theory suggests that dreaming evolved as a mechanism to enhance an individual's ability to deal with potential dangers and challenges encountered in the waking world.