Before tackling this, it's important to know what a dominant chord is. It's the V chord, and commonly the seventh is added, making it a dominant seventh chord. And you'll remember from our cadence lesson that the most common kind of cadence is V I, the authentic cadence.
After using the same scale forever with the same seven triads, composers looked for ways to get creative by using chords outside the key. Usually, these were brief journeys into the new key followed by a return the old key - just a brief key change to shake things up a bit.
A normal chord progression in a major key might go I IV V I. Very basic. Now, to make this longer and more interesting, let's briefly change key to the key of the V chord. It's only going to be a two-chord key change. And since the V I cadence is the strongest, we'll use this in our new key to "establish" it quickly. Our new progression will look like:
I IV V/V V I
The new chord there is a V/V, pronounced "five of five". It's a V chord in the key of the V of our original key. Putting chords to this, we get:
C F D7 G7 C
These chords have a tremendous capacity to move a progression along and create tension and resolution. Our ears don't really hear the D7 as a weird chord that's outside the key, but we hear it as a "pull" toward the G chord, which then resolves to the C.
One song that does this that most people know is "My Bonnie". It goes like this:
C F C C D7 G C F C F G C
This kind of sound happens all the time in modern music. It happens in jazz the most, but like most theory it's similar across lots of genres.
A short key change is called a tonicization, a longer one is called a modulation. Sometimes it's hard to tell which is which. If there's a bigger chord progression in the new key like I IV V I or something, you can call it a modulation.
You can do others besides just the V/V. The V/vi is pretty common too. Here's a sample progression (again in C major for simplicity):
I IV V V/vi vi ii V I
C F G E Am Dm G C
After you get the principle here, you can start doing all sorts of secondary chords. It doesn't even have to be the dominant (V) all the time!
One final application to dominant sevenths is stringing them along. So you're playing the V/V chord and think, "Well why can't we do the V of THAT key too? And the V chord of THAT key?" And so on. It can get a bit silly after awhile, but here's an example of a short string of sevenths that each resolve to the next one - and finally bring it back home to the I chord.
I IV V V7/vi V7/ii V7/V V I
C F G E7 A7 D7 G7 C
If you find a chord outside the key you're in and find yourself asking, "What's THAT chord doing there," secondary dominants are the first place to look for the answer. If it's not one of these, you can look for borrowed chords (I will cover this in another lesson).