Stabilizing multicellularity through ratcheting