The tonic water you add to your gin is carbonated water infused with quinine. This quinine has a bitter taste and is ground from the bark of the cinchona tree, native to the tropical Andean forests of South America. Sugar or fruit acids are added to tonic water as quinine alone would be too bitter to drink.
Early in the 19th century, Quinine was provided to British military personnel posted to tropical areas, to be taken as as an anti-malarial. The British colonials in India mixed the powder with soda water but the severe bitter taste led the troops to combine it with sugar, lime and gin. This 'Indian tonic' kept the British Empire safe and lubricated, and gave rise to the Gin and Tonic that we enjoy today.
Bottled sweetened quinine water followed, and aerated tonic water arrived towards the end of the 19th century. The carbonated 'Indian' tonic waters we know today have much lower levels of quinine and are artificially sweetened and flavoured. Tonic water is a beverage in it's own right, and is also mixed with tequila, brandy, and many other alcoholic and non alcoholic beverages. Citrus flavours can also be added, producing for example a 'bitter lemon' .
It's all about the gin really, and so pairing with the right tonic water is essential. All tonic waters are different, especially the variations within the same brand, and will affect the taste of any G&T. Some are sweet, some less so and lighter in taste, some more balanced, The quinine content varies, and some are flavoured. Along with the choice of garnish it can be seen that the taste of any gin is heavily influenced by its preparation.