What are some reasons that the bees swarm?
That's how they reproduce. A hive will split kinda like a single-cell organism. The hive will start to raise queens. Right around when the queen cells are capped they'll swarm. The old queen goes with the swarm and the old hive gets a new queen. Sometimes a hive will cast off follow-up swarms with virgin queens from extra cells. However most times the first queen out goes around and kills all the rest of the unhatched queens in the cells. Hives can swarm a couple of times in a season. We beekeepers try to prevent swarms by splitting hives and various other techniques.
They'll also sometime decide they don't like where they are living (pests, disease, etc.) and the whole hive will abscond.