The classic gin and tonic was invented in the tropics, during the Victorian era of Colonialism. Gin is a spirit which derives its predominant flavour from juniper berries, and was probably first invented for use as a herbal medicine. Tonic water is a carbonated water in which quinine has been dissolved and was originally used as a prophylactic against malaria. Quinine is bitter; it is what gives the pleasant bite to a bitter lemon cordial or soft drink. So all the ingredients of a gin and tonic had their origins in the medicinal pharmacy.
The cocktail was introduced by the army of the British East India Company in India. In India and other tropical regions, malaria was a persistent problem. In the 1700s it was discovered that quinine could be used to prevent and treat the disease, although the bitter taste was unpleasant. British officers in India in the early 19th century took to adding a mixture of water, sugar, lime and gin to the quinine in order to make the drink more palatable. Soldiers in India were already given a gin ration, and the sweet concoction made sense. Since it is no longer used as an antimalarial, tonic water today contains much less quinine, is usually sweetened, and is consequently much less bitter.
Excerpt from Wikipedia