APEX, N.C.—This Raleigh, N.C., suburb was declared the best place to live in America by a national magazine in 2015, around the time Lindsay and Terry Mahaffey were drawn by its schools, affordable housing and quaint downtown.

The couple found a sprawling five-bedroom house next to a horse farm for $782,000, half the cost they would have paid in the Seattle suburb they left behind.

Many...