IANAL and am mostly familiar with this type of situation from rom-coms about down-on-their-luck dukes who live in crumbling, unsellable castles, so I'm not sure if that scenario truly exists in law or if it's just a handy conceit.
> Or you might simply not have the money for the legal process to sell.
If your property is valuable, someone will be willing do that work for you in return for a cut of the proceeds. (And if your property ain't valuable, then the original comment doesn't apply.)
You hear about this a lot when people require certain kinds of care that Medicaid covers but Medicare does not. People will sign over all their assets (real estate, cars, financial instruments) to their spouse, then get divorced. All because the government doesn't consider you poor if you have wealth.