Explaining the concept of a musical key is difficult to do without having a keyboard at hand and giving little musical illustrations as you go along.
If you look at a keyboard, you will see that there are 12 possible notes to choose from: 7 white notes and five black ones. As it turns out, in most pieces of western music, a piece will use a set of only 7 of those notes, or at least, the piece will be based on such a set of 7 of those 12 possible notes. The key tells you which seven. For example, a piece in C major will use only the white notes. A piece in G major will be the same except that instead of using the white note F, it uses the black note to the right of F, which is F sharp.
Put a different way, think of the solfege syllables (Do, Re, Mi, Fa etc.) as a very simple melody. If you start that melody on C, you use only the white notes until you are back at C an octave higher. If you start on G, and use only white notes, then the F will sound wrong. To keep the melody the same you’ll have to use F sharp instead of F. Thus it will be the same solfege song in two different keys.
A further complication here is that F sharp is the same note as G flat - there are some rules to decide whether you should talk about flats or sharps.
If, like me, you do not have perfect pitch, it will for the most part not matter what key a piece is in anyway. But with some instruments, e.g. guitar, it can be vastly easier to play in some keys than in others, thus it is often useful to transpose a piece written for one instrument into a different key when you want to play it on some other instrument.
Two centuries ago, the definitions of the pitches were different, and orchestras tended to play everything about a half tone lower than they do today. So to someone like Beethoven, who did have perfect pitch, modern performances of his works would all sound like they are in the wrong key. Assuming he could hear them, that is to say…