This is the dominant of a chord that is not the tonic.
It is used to really spice up a progression.
It can also prolong the sense of tension in a song
if you precede a Dominant with its own Dominant.
It is very common to hear a progression of C-E-Am. E is out of key in C Ionian, yet it sounds really great.
That E is pulled from another scale, A Minor, and is Am's Dominant.