Repairing or replacing a slab foundation
Hairline cracks in a house slab are usually just shrinkage and mostly need watching. A slab that's sinking, heaving or split with one side higher is different, and the cause is usually in the ground under it. If the ground has stopped moving, I'd usually fix the section that moved before talking about a new slab, since replacing a slab under a standing house is a big job. A new slab makes sense for a new house, an addition or a slab too far gone to save.
What shapes the cost of a slab foundation
Size and thickness set how much concrete and steel the job takes, and post-tensioning, rebar and mesh each price out differently. The ground matters too, since extra digging, fill and packing add cost, and so does a tight site the truck can't reach. When budgets get trimmed, the base is the first thing people want to cut because nobody sees it. It's the last place I'd cut, because a slab on a poor base tends to settle and crack however good the finish looks.