The first chord a song or compositions starts (no matter is a modern song or classical music) is called "Tonic chord" and it's the most important because gives us the general key or Tonality of that musical creation, sometimes even appears as a part of the title of some classical music works (for example "Sonata in C Major"). Although Major chords are happy and minor chords sound sad, if the Tonic chord is minor (for example "a minor") that song or composition will sound sad although the remaining chords were Major (please note we are talking about the sound of the music not the meaning of the lyrics). As contrary if starts with a Major chord (like C Major) everything would sound happy.
In Harmony (and in tonality study in particular), there are two more basics chords funtions (apart from Tonic), but all this is not a "exact science": they may appear at the beginning or the end, only one of them, or in many forms or ways since depends of the type of music creation if it's simple like popular music or more elaborated or complicated. Even so, when talking about Harmony to people that are learning music it should be mention the presence the chords in funtion of Dominant and Subdominant since they form a basic where the classical music and music in general is founded; and could be compared to spelling rules or conjugation of the verbs of a language. To these should be added that if for example a song has only chords in Tonic, Dominant y Subdominant fuction generally would sound very poor.
The Dominant chord is the one whose "root note" (the note that gives name to it) is 5 notes both inclusive away from Tonic (3 tones and a semitone of distance) and the Subdominant is 4 notes both inclusive away from Tonic (2 tones and a semitone of distance). In other words if Tonic is number one (of this scale), Subdominant is number 4 and Dominant is number 5. If the Tonic is C Major, Dominant chord will be G Major and Subdominant F Major bacause G is located 5 notes away from C both inclusive (C, D, E, F, G,...) and F 4 notes away both incluse. Dominant chords could be Major or 7 (for example G 7). If the Tonic is E Major, Dominant could be B Major or B 7 and Subdominant A Major. In the images only appear, in treble clef, the basic notes that form the chords without duplicating them like it uses to happen when playing guitar or other instruments.
If Tonic is a minor chord, like a minor the Subdominant is d minor and the Dominant is E Major or E 7, in other words Subdominants in minor tonalities are minor chords but Dominants remain Major or 7 chords. This doesn't mean that in that case a e minor could not be include instead of E Major but it would not be considerate as a Dominant in the more traditional sense.
Another example: if Tonic is F Major, Dominant would be C Major and Subdominant would be B b Major because it must be separated from Tonic for 2 tones and a semitone and we "must use the flat" to reduce the distance in a semitone since B Major it would be "too far" (too treble) to be Subdominant. This happens because the distance between the notes e and f and between the notes b and c it's a semitone instead of a tone as the rest of the notes (for example from a to b or from c to d). Then, although you count 4 or 5 notes, there should be exactly 2 tones and a semitone of distance between Tonic and Subdominant, and 3 tones and a semitone from Tonic to Dominant.
Harmony is a subject from Conservatoire that studies chords: their formation and the relation between them, that study takes several years or courses. Therefore there are many more things to add to these topics, these are just some basics so people that are learning music can understand and can have a first contact with Harmony. But, how chords were formed? Which reasons took to the establishment of these standards?More recommendations:
Miguel Angel González Aguado offers guitar lessons and other instruments like piano and music theory lessons in which he explains all these concepts. In this website you can also learn to tune your guitar, to change the strings and put new ones, you can also read some useful and basic tips if you are going to buy a guitar or take better care of yours. You can also find information about the guitar lessons online that you can take from any part of the World.