Nicotine is naturally present in tobacco and most members of the nightshade family of plants (which includes many common vegetables such as potatoes, peppers, tomatoes, and eggplant), though it's much more concentrated (by several orders of magnitude) in tobacco.
The word "nicotine" is from the genus of the tobacco plant, Nicotiana tabacum.
Plants in the nightshade family form a variety of alkaloid compounds, including nicotine, capsaicin (the chemical that makes peppers hot), atropine (a medicine used to treat low heart rates, but fatal in large doses).
Nicotine is toxic to most insects (it is even occasionally used as an insecticide), so it gave the tobacco plant an evolutionary advantage. Some variants of tobacco are considered an invasive weed in some places because there are so few things that will attack it.