Ingredients of Root Beer
The primary ingredient in the root beer flavor is traditionally sassafras root. However, modern root beer uses artificial sassafras flavoring because the US FDA banned safrole, the oil from sassafras root. It is considered a weak carcinogen as well as a List I chemical by the DEA (used in the manufacture of illicit substances). 

Beyond sassafras the ingredients vary widely and drastically between manufacturers. The most common include vanilla, wintergreen, cherry/spruce bark, licorice, anise, and many more. A more complete list of root beer ingredients can be found on the wikipedia page.

If you're looking to make your own, I suggest finding a recipe and following it. Given the vast array of ingredients present, you'll have to do a ton of experimentation to stumble upon a suitable flavor without a recipe.