Jpeg jones has pretty much hit the nail on the head. I’ll try to expand a little bit upon it.
Any melodic line or riff can be harmonized by pretty much any chords underneath it. As stated above, an unexpected progression underneath a melody can really set it apart, and give it much more power or beauty.
You need to break it down to each melody note or sequence of notes. Lets look at a simpler melody than the Saitsfaction riff (which contains a non-diatonic tone):
E G A C D G C
There are several ways to approach this. First thing to do is determine the tonal center of the melodic fragment. in this case, the most obvious choices are the keys of C and G, as all the notes in the melody occur naturally in both keys.
At this point, you can harmonize the riff with one chord per pitch, or with multiple pitches to one chord, or with multiple chords to one pitch. With me so far?
One pitch, one chord:
You can use any chord you want. The ‘rightness’ of the harmonization is subjective, but obviously the less ‘outside’ the pitch is to the chord, the more natural it will sound to the casual listener. So you could use an F major chord to harmonize that first E note, but there will be some significant harmonic tension and dissonance there, as the F natural would be a b9 (bii) in the key of E. Lets’ go a bit simpler.
Let’s take a sequence of chords in which each melody note occurs naturally in the chord, and to keep it harmonically simple, we’ll also only use chords that occur diatonically in the key of C, for this example.
So we can do this:
**E | G | A | C | D | G | C**
C major | G major | F major | A minor | D minor | G major | C major
nice, pretty harmony, with just a touch of movement.
alternately, we can go with multiple pitches per chord:
E G | A C | D G | C
C major | F major | G major | C major
All still very clean, and all pitches are naturally occurring within the underlying chords.
You can spice it up a bit, if you like, by going slightly outside the diationic key:
**E | G | A | C | D | G | C**
C | A7 | D | D7 | G | G7 | C
This starts adding borrowed chords and starts to imply more advanced chordal motion. You’ll notice, however, the underlying chords still contain the melody pitch, albeit in different places: the G (meas. 2) is the dominant (flat) 7th of A major, thereby making A7, the C (meas. 4) is the dominant (flat) 7th of D major, thereby making D7. The D and the G near the end are both contained within the G and G7 chords - I just used that chord change to continue the harmonic motion and to lead a bit more strongly to the tonic ©.
So as you can see, you can pretty much do anything you want when you’re harmoinzing. Rule of thumb while you’re just learning this - make sure that the melodic pitch occurs SOMEWHERE in the chord you’re sticking underneath it, and try to get some strong motion happening between the chords (I-IV, V or V7-I, ii-V, etc)
I’m gonna stop here, because I’m in danger of going into a major lesson on chord harmonization, but if you have any specific questions, feel free to ask 'em
-Picker