Most people actually would rather stay in HK to take advantage of the better education and healthcare system for their children than moving to China for a __slightly__ more affordable place. HK is also a much safer city to live in. The food is generally safe and the police is fair and professional.
Commuting between HK and China is also a big problem. Most jobs in HK are in the urban areas in HK, commuting from Shenzhen or elsewhere to those areas daily can take a huge chunk of money out of their wages, let alone the 3-4 hours they have to spend commuting.
I used to work with people who commute from Island South to SZ, but they only do it on Friday night and come back on Monday morning. In general, people living cages neither have the money nor time to commute.
You're saying housing prices on the mainland are only slightly more affordable than in HK? That's absurdly inaccurate. Housing is cheap on the mainland outside of prime areas of big cities. The job market is another story, the earning power in Hong Kong is much better - along with the other things you mentioned.
Many of these people are trying to make a better life for themselves and especially their children. To get there, they are dealing with horrible living conditions. I salute them for that. My grandfather did something similar coming to America from Italy and his whole family is eternally grateful. Future generations of HKers are going to feel the same way.
The median income in HK per household per month is HKD 18000 in 2010[1] (USD ~2300). Everything you can buy in HK is essentially NYC prices. You can't feed your family with this income, so they are living in HK, taking advantage of free education and healthcare. There is also no "Chinese rural areas" anywhere near HK. HK is an island and a peninsula. North of HK is Shenzhen, also a big metropolitan area. There's no commuting to these "rural areas" that's feasible. Also, to commute to China, you essentially have to leave your children in China, otherwise you'll be leaving your children in HK, and take a job in China instead, which defeats the purpose.
The problem is these people generally have little skills so their job prospects are pretty terrible anywhere. In reality, if you have a stable job, or possibly a family, you'd be living in public or subsidized housing instead of a cage. But that's no longer possible in the last decade since the government had stopped these programs.
Shenzhen is still much, much cheaper than HK. I had a 2 bedroom 90 square meter apartment in Shenzhen in a brand new building and a nice part of town for 3,000 RMB/month. The same in Hong Kong would have been roughly 10 times more expensive. And Shenzhen is an expensive mainland city.