Just what people know from experience. I don't think there is any particular mechanism.
But if a colony is dug up the ants see this as an attack. They will try to relocate but instead find themselves in an artificial environment with few options.
Whereas a single queen in a test tube quickly decides "yes I must have dug this perfect little hole" she quickly becomes less concerned with constantly fluctuating light & vibrations. All the workers have never known anything else.