Let's break down a major key...
In the key of G major the notes are
G, A, B, C, D, E, F#, (G)
Then we built a triad chords from these notes taking a root, a third and a fifth note.
G - B - D
A - C - E
B - D - F#
C - E - G
D - F# - A
E - G - B
F# - A - C
Now let's analyze the intervals of each triad
G - B - D
is a root, a major third (four half-steps) and a perfect fifth (seven half-steps from a root). There is a major third interval, this makes a chord major, G major in this case.
A - C - E
is a root, a minor third (three half-steps) and a perfect fifth. There is a minor third interval, which makes a chord minor, Am in this case.
B - D - F#
is a root, a minor third and perfect fifth. Again a minor third interval. The chord is a minor, Bm.
C - E - G
is a root, a major third and perfect fifth. This time a major third interval. The chord is a major, C.
D - F# - A
is a root, a major third and perfect fifth. Again a major third interval. The chord is a major, D.
E - G - B
is a root, a minor third and perfect fifth. Again a minor third interval. The chord is a minor, Em.
F# - A - C
is a root, a minor third and diminished fifth (six half-steps from root). The chord is a diminished, F#°.
In general
- all the triad chords with a root - [u]a major third[/u] - perfect fifth are major chords.
- all the triad chords with a root - [u]a minor third[/u] - perfect fifth are minor chords.
The major key triad chord formula is always
major - minor - minor - major - major - minor - dim
regardless of what key we are in.
In G major this is G - Am - Bm - C - D - Em - F#°.
The chord degrees are typically marked using a roman numerals, so, that major chords are marked with a UPPERCASE letters and minor chords with a lowercase.
Then the general major key chord formula is
I - ii - iii - IV - V - vi - vii°.