what is it used for, and how and why might it appear in literature?

its used to make an obvious exaggeration
like "to wait an eternity"

"Hyperbole is a figure of speech which is an exaggeration. Persons often use expressions such as "I nearly died laughing," "I was hopping mad," and "I tried a thousand times." Such statements are not literally true, but people make them to sound impressive or to emphasize something, such as a feeling, effort, or reaction. "

the structure of hyperbole