Summary:
Barbarians come from "encampments", which may appear randomly in any tile that cannot be seen by a unit. Every few turns the encampment will create another barbarian unit which will make a beeline for the nearest civilization and start causing trouble. The only way to stop this is to find the encampment and destroy it. Encampments are usually guarded by at least one unit, so they're not pushovers.