Usage of characters

Fiction books have this disclaimer in them: “This is a work of fiction. Any resemblance to living persons is purely coincidental.”

This is fine and dandy, but it’s no secret that authors often base characters in their books on real people, or at least composites of real people. Is the disclaimer just something thrown in for legal reasons?