The Gin and Tonic history is filled with myths and legends. One of the most famous stories implies that British navy soldiers invented it for Malaria prevention. Supposedly, they mixed the bitter-tasting and quinine-packed tonic water with Gin to make it more palatable.
Another legend goes that officers of the Indian Army invented the Gin and Tonic in 1825. According to that, soldiers had taken their daily dose of quinine with Gin and soda.
That would have been only five years after quinine was extracted from cinchona bark for the first time. Yet, even though Gin, quinine, and soda were available in India at the time, it is unlikely that this is the true origin of Gin and Tonic.
To get closer to the true origin of our beloved Gin & Tonic, it only makes sense to first look at the history of its two main components.
The origin of Gin
William III of England, also called William of Orange, exported Genever to England and renamed it Gin in the 17th century.
During one of the Anglo-French wars in that era, importing French products wasn't well-liked. The result was a severe spirit shortage in England, leading the British Parliament to enact the Distilling Act in 1690.
Consequently, the British were eventually allowed to make their own Gin - which had been prohibited until then. That is how the spirit became more and more popular.
Another change of laws, the Bank of England Act 1694, also known as Tonnage Act of 1694, led to an increased Gin consumption. The tonnage act enabled the government to collect duties on arriving ships according to their tonnage.
With this change of customs, beer was suddenly heavily taxed and became as expensive as Gin. Subsequently, Gin got another big push as more and more people decided to drink the stronger and now seemingly affordable juniper spirit. Especially the working class switched to this new spirit, starting the so-called "Gin Craze."
Consumption peaked in the 18th century and not in a good way. People, including young children, got addicted, leading the government to restrict production and consumption.
In the aftermath, they passed the Gin Acts in 1729. From then on, illegal distilleries got prosecuted, and selling Gin was only allowed under a license.
But despite the negativity, Gin became the national spirit of England. Soldiers in every part of Britain got their Gin rations, including forces of the East India Company (EIC) located on the Indian subcontinent.
That is the root of the myth that the Indian Army invented a precursor of the Gin & Tonic at the beginning of the 19th century, in 1825.  However, there's no written evidence or hint that supports this myth. Quite the opposite, in fact, because tonic water had not yet been invented. The research on extracting quinine was only a few years old at the time.
The invention of Tonic Water
To produce tonic water, men first had to find a way to extract alkaloids in cinchona bark. Joseph Bienaimé Caventou and Pierre-Joseph Pelletier were the first to succeed in 1820. As a byproduct, they discovered quinine, the bittering agent in tonic water. 
Their quinine could only be dissolved by adding acid or alcohol, and it took over a decade to change that. According to Kim Walker & Mark Nesbitt, the first written mention of quinine dissolved in a non-alcoholic and non-acidic liquid dates back to 1835. An advert in the Bristol Mercury mentioned the special soda water.
As a reminder: this is ten years after the first Gin and Tonic supposedly was invented. And the invention of the first real quinine-flavored tonic water was even later.
On May 28, 1858, businessman Erasmus Bond filed a patent for quinine-flavored soda water. He named his creation "an improved aerated liquid, known as Quinine Tonic Water" and advertised it as Pitt's aerated tonic water. Proof of his patent plans is in a clipping from the London Gazette of October 12, 1858. 
In the early 1870s, there were products from numerous competitors on the market, including Schweppes Indian Tonic Water. Unlike Bond's patented Tonic Water, it used citric acid instead of sulfuric acid to improve quinine solubility.
Gin and Tonic - A Malaria treatment?
So we have unsubstantiated claims that the early Gin and Tonic used to be a malaria remedy and a precisely documented timeline of the invention of tonic water. Unfortunately, the two do not fit together at all.
The myth itself, of course, has a coherent story. Quinine generally helps to fight malaria. And since this medicine didn't taste very good, the soldiers improved it by adding Gin. The problem with this story is that it is unlikely that the soldiers were actually able to make tonic water.
Additionally, in a study performed by the department of Molecular Medicine, Bernhard Nocht Institute for Tropical Medicine in Hamburg proved that it would have been almost impossible to consume enough tonic water and absorb enough quinine to fight malaria. 
The book Just the Tonic. A natural history of Tonic Water proves the British Army did not use quinine to prevent malaria until the 1850s (on pages 91-92). And even then, there's no mention of a Gin & Tonic.
After all, the first patent was not filed until 1858 by Erasmus Bond. So when and how was the Gin and Tonic really invented?
So the Gin and Tonic was probably not a medical aid against malaria. Kim Walker and Mark Nesbitt state in their book "Just the Tonic. A natural history of Tonic Water" there was no written evidence Gin was mixed with tonic water until 1868.
That year, the Oriental Sporting Magazine from Calcutta, India, mentioned it in connection with horse races.  Stating that "...Loud cries of „Gin and tonic,“ „Brandy and soda,“ „cheroots,“ &c., told us the party was breaking up for the night, and we wended our way home …“
In 1875, the second written mention in the Medical Press - Indian Medical Notes appeared. It listed the Gin and Tonic as a frequent item on an army officer's daily agenda: After tea in the morning at 5 o'clock, there is breakfast between 9 and 10, and later in the club, either a sherry with bitters or an ice-cold Gin and Tonic. 
A letter to the editor in The Sporting Times of April 28, 1881, also shows that in the late 1800s, tonic water was hard to come by in England. That is consistent with other statements that Gin and tonic was a rather tropical drink until the 1920s.
„To the editor of the ‚Sporting Times‘ Dear Sir, – Why, in the name of all that is mysterious, is not tonic water procurable in England – the land that boasts almost every kind of mineral water? I have passed a good portion of my life in the land of India and have now just returned after a six years‘ sojourn in that country. India has its blessings, as well as its – well the reverse of blessings – but one of its greatest enjoyments is the pleasant ‚peg‘. We have out brandies and sodas, as well as other drinks procurable in this delightful country, but we fail to find here the drink most patronised in India, viz., gin and tonic. Of course, the gin is to be had, but where is the tonic? This question I want to ask you, you may be able to answer it or if not, by kindly inserting it in the Pink ‘Un it may catch the eye of an old Indian, and he may be able to inform me through your paper if I can obtain, and if so, where, the drink required. I am, sir, yours faithfully, ANGLO-INDIAN. April 28th 1881.“Letter to the editor in The Sporting times, 1881
These assertions and the conclusions drawn also appear on pages 113 and 114 of Nesbitt and Walker's book. -That only makes sense since all early provable mentions of the drink come from India.
However, what is striking, is that Gin and Tonic is always mentioned as refreshing drink, never as medicine. Thus, it is highly likely that it was never a potion to fight malaria. It seems that this myth was a way to make the cocktail more popular.