Short answer: Ants are outstandingly cool.
Long answer: Well, there’s two questions here: what makes a better nest for an ant, and how do they collectively decide to go elsewhere? The former depends on what species of ant you’ve got, and we’re certainly nowhere near fully understanding what motivates a move, but general criteria (link, pdf) for a good nest might include:
[ul][li]High cavity ceiling[/li][li]Small entrance gaps[/li][li]Relative darkness[/li][li]Floor area (and yes, there have been experiments [link, pdf] showing that scout ants can assess this)[/ul][/li]Undoubtedly it’s bit more subtle than that, but these are the sort of things that a scout ant appears to take notice of when out looking for new potential nest sites. Generally a search for a new site is prompted by damage to the current nest, which could be caused by a number of things; some sort of invading predator perhaps, but more likely just some damage to the structure of the nest which has decreased its desirability. I’d bet a bit of their nest collapsed, prompting a search.
So, once the scouts are out and looking, how do they aggregate this knowledge and take a decision? Here it gets even more ace. It depends on the ant species, but in the second article I linked to which studied leptothorax albipennis (chosen because colony size can be small, and thus amenable to study), a scout finding a nice spot will start individually recruiting fellow scouts to come and have a look. Some species use pheromone trails to do this; leptothorax goes and deliberately finds a receptive scout, and leads it all the way to the potential site by “tandem running”, where the follower continually taps the leader’s abdomen with its antennae to let it know it’s still behind it. The recruited scout then has a peek, assesses the site itself, and goes off to recruit more scouts if it thinks it’s nice too. In this way, knowledge of potential sites is spread around the scouts, and (hopefully) the best site gets the most recruiters. Later, when sufficient scouts have been convinced that the new site is ace, things change to a faster recruitment method, whereby the ants will just pick up recruits and carry them to the new site. This is faster, but the recruit won’t know how they got there, which is why this is left until the move is more certain.
So that’s how word gets around, but how is the collective decision made? Well, this is all a bit more speculative, but there have been some computer models (link, pdf) created in the field of multi-agent systems that claim to reasonably simulate the behaviour of an ant colony whose current nest has been destroyed. Essentially, damage to a nest will prompt a shift in the population where about a third of the colony will start actively looking for new sites (the scouts). How this shift happens is somewhat vague; certainly the colony isn’t constantly seeking new sites, since the work involved in a search (not to mention the move itself) is considerable. Certainly individual ants must be able to recognise damage to the nest, so it’s possible that no collective “decision” is taken in any real sense. In any case, by going looking in the first place, they’ve basically “decided” to move, and the recruitment mechanism described earlier is how things snowball into the migration you saw.
Essentially it’s an algorithmic competition between potential sites: better sites attract more recruiters, and because of the way recruits become recruiters, the number of ants committed to a particular site should grow exponentially, resulting in the sudden migration of most of the population. If there are multiple approximately equivalent nest sites, then it’s possible for the population to split, but this seems to be rare. Sometimes you get a small offshoot going to an inferior candidate site, but then those tend to get recruited to the superior site and form a second migration.
Hmm, that went on for a while. As I say: ants are ace.