Someone else will be able to give the history of the totenkopf symbol in a German military context, but it was not just used by Prussian/German military organisations. The British Army still has a cavalry regiment which uses the totenkopf symbol as part of their cap badge. It's a good opportunity to give a potted history of some aspects of the cavalry regiments of the British Army and explain why that badge was chosen, when it was chosen, and why it is still used today.
In the early history of the British Army (ie: during the late-17th and early 18th century), cavalry was divided into two types: horse and dragoons. It's a slight oversimplification, but broadly speaking horse were the heavy cavalry who were to use their mass to charge the enemy and fight hand-to-hand. Dragoons were mounted infantry, armed with sabres but also carbines. In theory, they were expected to fight as well on foot as they were mounted. Both types gradually merged together, with horse's role gradually becoming lighter and the mounted infantry aspect of the dragoons' theoretical role giving way to the things we usually associate with light cavalry: reconnaisance, posting vedettes and using their speed and agility on the battlefield.
Complicating things slightly, there were also the cavalry regiments of the sovereign's bodyguard. Nowadays they're known as the Household Cavalry, but in this early period they comprised several separate cavalry regiments known variously as The Horse Guards, The Life Guards, The Blues, The Horse Grenadier Guards and so on. These were heavy cavalry in the traditional sense and were viewed as exclusive regiments: the officers and other ranks of the Life Guards and the Blues were drawn from the nobility, whilst the officers of the Horse Grenadier Guards were aristocrats and the other ranks were commoners. There was a consequent association of heavy cavalry with high status, which played into some decision-making later.
Because of the merging of the roles of horse and dragoons, the term "horse" to describe heavy cavalry was abandoned in the mid-18th century. Instead, all cavalry which did not form part of the Household cavalry was designated "dragoons". This also saved money, because dragoons were paid less than horse and were mounted on lower-quality horses. The association of "horse" and heavy cavalry with status meant this change was unpopular with the former Regiments of Horse. To alleviate this, it was decided that all former dragoon regiments would be known as Light Dragoons, and the former horse regiments would be designated Dragoon Guards. This was an obvious attempt to link the new heavy cavalry regiments with the regiments of the Household cavalry, if only in name.
As the numbering system of British line cavalry regiments solidified, and this change to the nomenclature of cavalry also settled, from around the 1750s all regiments numbered 1st-6th were Dragoon Guards (ie: heavy cavalry), and those numbered 7th and upwards were Light Dragoons.
Now, the totenkopf badge.
In 1759, John Hale of the 47th Regiment of Foot returned from Canada with the final dispatches from General James Wolfe detailing his campaign and victory in North America. As was customary, the person bringing these dispatches was rewarded. In this case, Hale was granted land in Canada and given the right to raise a regiment of Light Dragoons. He formed the 18th Light Dragoons, or Hale's Light Horse, in November of that year. He chose the totenkopf badge as the emblem of his new regiment, and in particular the motto "Death or Glory". In this case, the badge was the skull and crossbones, with the words "Or Glory" underneath, with the totenkopf badge signifying death. This was a direct commemoration of the death (and consequent glory) attained by Wolfe in Canada. The idea was clearly to imbue his regiment with the same commitment. With a few re-numberings, the regiment was finally designated as the 17th Light Dragoons in 1769.
Although the British Army had never raised regiments of lancers, a decision was made in 1822 to formally re-designate several light dragoon regiments as lancer regiments. Because several other Light Dragoon regiments had previously been re-designated hussar regiments, this change meant that the designation "light dragoon" was no longer in use within the British Army. Interestingly, the designation was resurrected in 1992 when 13th/18th Hussars and 15th/19th Hussars were amalgamated. The new regiment was called The Light Dragoons to continue the tradition of the British Army's original light cavalry regiments.
After being told to adopt the lance, the 17th Light Dragoons became the 17th Lancers, and kept the totenkopf cap badge and the "Death or Glory" motto. It was formally designated the 17th Regiment of Lancers in 1861, and became 17th (Duke of Cambridge's Own) Lancers in 1876.
Several large-scale disbandments and amalgamations occurred in the British Army after the First World War. These were partly to remove the Irish regiments from the order of battle after the end of the Irish War of Independence, and partly to save money due to the cost of the First World War. Several cavalry regiments were amalgamated, and 17th Lancers was amalgamated with the 21st Lancers to become the 17th/21st Lancers. The new regiment kept the Death or Glory cap badge and motto of the 17th Lancers. That regiment was in turn amalgamated with the 16th/5th The Queen's Royal Lancers (itself formed by amalgamation in 1922) to form The Queen's Royal Lancers in 1993. Again, the totenkopf badge was retained, this time combined with the crossed lances of the 16th/5th Lancers.
The badge continues in use today. In 2015, The Royal Lancers was formed when the Queen's Royal Lancers amalgamated with the 9th/12th Royal Lancers. It was re-named The Royal Lancers (Queen Elizabeth's Own) in 2017. The cap badge continues to include the totenkopf, the Death or Glory motto and the crossed lances of its predecessors.
From an earlier answer of mine
Although the SS's use of the skull and crossbones suggests they were the baddies, the emblem and its attending black uniform had a long heritage in German military history that the SS sought to co-opt. The symbol originated in the armies of Frederick the Great and a unit of Hussars, but it gained wider notoriety during the Napoleonic Wars. Napoleon had dissolved the Duchy of Brunswick and absorbed into the Kingdom of Westphalia. The duchy's dispossessed Duke, Friedrich Wilhelm, raised a regiment and offered his service to the opponents of Napoleon. The "Black Brunswickers" had as their uniform colors stark black (some also wore green) and emblazoned their shakos with a white metal Totenkopf. The regiment served both in Austria in 1809, the Peninsular War, and in the Hundred Days where Friedrich Wilhelm died at Quatre-Bras. The activities of the Black Brunswickers as well as their stark uniforms became potent symbols for the romanticization of the Napoleonic Wars, such as Milias's famous 1860 The Black Brunswicker and Friedrich Matthäis's Tod des Schwarzen Herzogs. A regiment of the Brunswickers survived the Napoleonic period and was incorporated into the Prussian army after unification. Their emblems and battle honors remained an important part of their traditions, as seen in this photo of the Hohenzollern Princess Victoria Louise in a tailored uniform of the regiment which functioned as a life guard regiment for the imperial house.
The skull and crossbones became an unofficial emblem for various German units during WWI, such as their embryonic tank corps and their badges. The Totenkopf underwent a further iteration under Weimar where it was adapted as an emblem for some of the Freikorps, such as in this photo and later used by some of the panzer troops after Hitler's seizure of power as they saw themselves as the heirs to the Hussar tradition. Some aircraft in the Condor Legion used the emblem in the Spanish Civil War. The Luftwaffe's KG 54 bomber wing used the Totenkpf, such as in this photo of a Ju 88. The SS modified the Totenkopf design, making it more angled and squat, to differentiate themselves from earlier and contemporary versions.
The emblem by the SS covered two major bases. Firstly, it set itself up as an elite that was personally connected to the leader of Germany and his protection. A Totenkopf was a clear symbol of this as it was a recognized heraldic device that conveyed this message. The Black Brunswickers held themselves as an elite unit, and this was an image the SS cultivated as well. Secondly, the Totenkopf was laden both with contemporary and historical meaning that the SS desperately wanted to connect with. The Black Brunswickers were a formation that wanted to overthrow foreign domination of Germany, and this was a tradition that meshed well with the rhetoric emanating from the NSDAP about the Weimar period. Like many National Socialist organizations, the SS sought to portray itself as the culmination of German history and its true heirs. The irony is that the SS were arguably so successful in co-opting the Totenkopf that SS's use of this symbol overshadows its use in earlier periods German history.
Firstly, if you came here to comment a variation on 'are we the baddies'...you might be the baddies. Because the more comments referencing the Mitchell & Webb sketch, the more likely it is that people looking at the thread as they browse Reddit will think there might be an actual answer here...but nope, it's just people making Mitchell & Webb references. With that out of the way...
Welcome to /r/AskHistorians. Please Read Our Rules before you comment in this community. Understand that rule breaking comments get removed.
#Please consider Clicking Here for RemindMeBot as it takes time for an answer to be written. Additionally, for weekly content summaries, Click Here to Subscribe to our Weekly Roundup.
We thank you for your interest in this question, and your patience in waiting for an in-depth and comprehensive answer to show up. In addition to RemindMeBot, consider using our Browser Extension, or getting the Weekly Roundup. In the meantime our Twitter, Facebook, and Sunday Digest feature excellent content that has already been written!
Please contact the moderators of this subreddit if you have any questions or concerns.