The harmonic function of a chord is mainly a combination of two factors.
1. The strongest and the primary factor is the presence of the 6th or the 7ths degree of the scale in the triad
- any triad containing the 6th degree has subdominant function (II, IV, VI).
- any triad containing the leading tone 7th degree has dominant function (III, V, VII), where the III of the major scale is rather weak as the dominant and rather falls into the third group below.
- any triad containing the natural (Aeolian) 7th degree belongs to the third functional group, the name of which I don't know, if it exists.
- the raised 6th of the melodic minor could be considered as giving rise to a special flavor of subdominant group (with a questionable member of the diminished root position chord on the 6th degree, thus instead one could rather simply apply the second rule below to the remaining II and IV chords with raised 6th degree of the scale)
- note that thereby the tonic triad is the only one not belonging to one of the above mentioned groups.
- sometimes this rule makes no difference (e.g. the first inversion of the IV triad is built from the 6th degree of the scale as the bass, which still implies a subdominant-group root position chord)
- sometimes it makes a difference (e.g. the first inversion of the tonic triad is built from the 3rd degree and often can function as the root position III chord)
- in the sense of this rule, all chords built from the same bass have the same function regardless of the notes above the bass (thus, e.g. first inversions of triads should be rather considered as chords with added 6th, and second inversions as chords with added 6ths and 4ths)
- the rule clearly contains the case of adding higher-order tones to the chord (the 7th, the 9th, etc.), but also the 2nd, 4th and 6th (if the latter are not considered as the 9th, 11th and 13th).
- if the tones above the bass include the 6th or (especially raised) 7th degree of the scale, the first rule tends to dominate and the bass note tends not to matter in regards to the harmonic function, especially if this tone belongs to the respective triad (e.g. the first inversion of the leading-tone triad has a stronger tendency to work as a dominant chord rather than as a chord of the 2nd degree of the scale with added 6th)
In composition practice I find it most convenient to use the two factors in the opposite order, concentrating on the second factor as the primary means to plan the harmonic function and then being aware of exceptions (mostly rising from the cases in which the functions defined by the primary and the secondary factors are different and the primary factor wins).
Disclaimer: these rules are actually my attempt to express my own intuitive understanding rather than a formal list that I'm following. I possibly have missed some points and may refine them later.
Comments, thoughts, feedback?