In the Caribbean during the 17th Century, sugar farming was rife and a major source of income. However, once the sugar cane (Genus Saccharum) was harvested, crushed and boiled, it would leave a viscous liquid by product when producing the sugar. This by product was molasses.
As well as having no practical use at the time, the molasses were produced at an astounding rate of 50% of the amount of sugar created. The sugar plantation owners fed the by product to cattle and the slaves, but there was still too much being produced.
Miraculously, the plantation slaves discovered that the molasses could be fermented into alcohol. This initial process was refined and distilled to remove impurities to create the first rums ever.
I recommend the following couple of books if you are interested in finding out more about rum and its history:
Please feel free to add any others in the comments section which you think are worth a read.