The QWERTY keyboard layout was established in 1874 by Sholes & Glidden typewriters. Every language has certain keys that are used more often, like in English the letter W is one of the most used letters in our alphabet. However in Spain it is a very rare letter to use, and if used it's many times because of anglicised words. Same goes for the german languages, the Y is rarely used, so to place it in the centre of the keyboard or "kezboard" as the german QWERTZ layout is nicknamed, wouldn't really make much sense. Instead the Z is used much more often. These small variations have few documentation so we can't be completely sure to the actual reason, but it seems to be pure comfort of certain language users. The QWERTZ layout is not only used in Germany though, also throughout the Balkans, Austria and to some extent even Eastern European countries like Poland, Czech Republic, Romania...
As to the different symbols, it's purely based on usage of native writers. In France and Spain you will have a lot more accent symbols and in Germany there are more Diaeresis or Umlaut characters.
Fun fact, in Spain we have 4 different languages which means we have keyboard variations in our own country. In Catalonia we speak Catalan so we have keys like ç or · which on the Spanish keyboard are not available as they don't use those symbols.