When a song consists of notes from a particular scale, it is said to be written in the key which has the same notes as that scale. For example, if a song contains mostly notes from the C major scale, it is said to be in the key of C major.
The following song is in the key of C major. Notice how the melody notes fit with the chords. For example, the melody goes to a D note at the same time as the D minor chord occurs. Notice also the use of sequence patterns in this melody.