The reason some of the chords within a key are major while others are minor (and one diminished) is that they are made up of different intervals. An interval is the distance between any two notes.
One interval you already know is the octave, which is the distance between a note and its next occurrence at a higher or lower pitch after passing all other letter names used in between. All intervals have a specific name based on how many letter names apart the two notes are. For example, C to D is called a second, as is D to E, or E to F.
C to E is called a third, as is D to F or E to G. C to F is called a fourth, etc. The use of sharpened or flattened degrees in scales or chords (e.g., a flattened third in any minor chord) complicates the naming of intervals. To get an overview of all the possible intervals contained within an octave, let’s look at the C chromatic scale, which contains all possible notes between one C note and the next C note an octave higher.