Sometimes a woman is here on a family visa as the partner of a British man (or a man with ILR). He dumps her and disappears, leaving her pregnant, with no recourse to public funds and no valid visa (because she's no longer his partner).
If she has other children with a right to remain in the UK she can apply to change visa and be here as their parent instead but she may not have the money or necessary access to immigration advice.
If she can evidence domestic abuse and that she is destitute (this is way beyond the level of any DWP means test) then she can apply to have NRPF lifted and her route to settlement will double from 5 to 10 years. This depends on her knowing about this and again, being able to find help and advice to apply.
Otherwise she becomes someone who is here illegally and will be required to pay 150% of the cost of her maternity care, even if the child she is giving birth to is British. They don't chase the British/settled man for his half of the bill, it's all on her, even though the Home Office obviously knows exactly who he is.
Or there may be an ordinary happy family - British man, wife on a family visa, maybe an older child from wife's previous marriage who is on her visa, maybe a younger child in common who is therefore British. They both work but are on low wages. She has NRPF so they are not entitled to the same level of in-work benefits as other families. They are one payslip away from a clusterfuck, same as most families in the UK.
They've been together here for 2 1/2 years and visa renewal time is coming up so they need to raise:
£1048 visa fee for the woman
£1048 visa fee for the non-British child
£1560 healthcare surcharge for the woman
£1175 healthcare surcharge for the non-British child
It will cost this family £4831 just to be legally allowed to live together in the UK for the next 2 1/2 years, after which there will be another hefty bill.
Maybe they just don't have it. Maybe they were saving diligently but covid or inflation or ludicrous rent rises, a job loss or health issues got in the way, the same as can happen to any other family.
So this family quietly become overstayers because there's no mechanism for contacting the home office and explaining your situation to someone with the authority to act like a normal person and arrange an affordable payment plan.
Maybe their late renewal application is accepted, or they are given different leave to remain on human rights grounds, even if they have run up NHS debt while not covered by the healthcare surcharge.
The immigration rules allow for leave to remain to be granted even if a person owes money to NHSBSA, up to a strict limit.
Leave to remain also includes leave to re-enter the country.
It is possible to end up with a criminal conviction for non-payment of some debts (e.g. council tax) but not until it's been to court and you have failed to comply with a court order.
In this family's case, only the woman would be detained. Her husband with the British passport would sail through a different queue.
Sometimes this happens the other way round and a dependent husband ends up detained but not usually. And obviously, no British women are dumping their pregnant husbands with LLR and NRPF.