I think in theory it sounds good, but not in reality. Quite honestly, there are many teachers, etc. that just can't afford to live in the cities or towns in which they work.
Also, I know Boston has the residency requirement, and it seems to only "apply" to certain people.
This would be a serious issue. In the town DH and I grew up in the current median income is something like $180K and house prices are insane. We were living there for two years while H was in grad school and the 2 bed/1 bath <1,000 SF house on a busy street we were renting is currently on the market for $360K. There are no multiple dwelling units in the entire town (it is 100% SFH). The teacher salaries cap out at well under $100K. There's no chance teachers can live in town.
Although my answer to that is that if you put that requirement on public servants you must pay them enough that they can afford to live there, full stop. In all honesty, I do feel that it's pretty disgusting not to pay teachers and police officers enough that they could live in and be part of the community if they desire to (even though I also feel that most want separation between professional and personal lives and should be allowed to choose not to anyway).