Summary:
Barbarian encampments can create almost any kind of unit in the game - from warriors and spearmen to cannon and tanks. (They can build units equal to those that the most advanced civilization can create.)
Once created the barbarian units will either hang around their encampment or head off toward the nearest civilization or city-state and try to cause trouble. They'll attack units, destroy improvements and menace cities. If enough are involved, they can take down a poorly-defended city, which is then thoroughly pillaged. A pillaged city may lose gold, buildings and population.
This is why it's important to periodically sweep the countryside around your civilization, destroying encampments before they become a threat.