What is the idea behind a key in music?

I'm currently learning a bit about music and up to now most music I've come across has been wrote in a key of C. Now I know that the sharp/flat symbols at the beginning of the stave denote what key the music is played in, and ultimately which note each of the lines in the music represent (like in a key of... show more I'm currently learning a bit about music and up to now most music I've come across has been wrote in a key of C.

Now I know that the sharp/flat symbols at the beginning of the stave denote what key the music is played in, and ultimately which note each of the lines in the music represent (like in a key of C notes between the line represent A-C-E where as notes with the line going through them represent GBDF)

But then when you add a key to the beginning this then all changes - one song I was looking at recently is Axel F as the base of it is quite a simple song (mainly A-C-A-A-A-D-A-G repeated) and yet I notice on most websites that says it was wrote originally in a key of A flat Major which now means the Treble Clef is now resting on the B line not the G line any more (I think that's right?) - so is there any reason why A flat Major was chosen over C Major? Was it just the writers preference at the time or is there specific logic in it?

Please excuse me if you think I'm being a bit ignorant towards the complexities of sheet music with this question as at the moment I'm only just basically reading the music and am currently learning to play clarinet so just wondered if someone could shed some light on why we use keys at the beginning of music and not just write everything in C Major - I'm guessing there must be some kind of reasoning here?
4 answers 4