In Mississippi and South Carolina, you can buy a house in many areas for sub-$100k, for a 1:2.5 salary-price ratio. Compare to Silicon Valley, where good tech salaries of $200k and 2 bdrm homes for $800k give a 1:4 ratio.
$40k is middle class for that part of the country.
The difference in costs for everything else is similar or worse in rural areas though. For instance, a 32" TV costs the same on Amazon no matter where you live, but when the water company only has 900 customers instead of a few hundred thousand the cost-per-gallon sky rockets.
A one hour commute could easily cost ~ 5k/yr in fuel alone (50 weeks * 5 days * $3/gal fuel * (60miles / 20mpg)), instantly cutting that increase from 30k to 40k in half.
$40k is middle class for that part of the country.