Good schools are not poorly built or poorer than bad schools because it's tax payers' money that feed the schools. Normally good public schools are located at wealthier areas, worse performing schools are located at lower income areas. Can you see why good schools usually also have nicer facilties? Because the property tax is higher in wealthy neighborhoods or wealthier cities.
Your story is probably not entirely true regarding the good and bad schools. Teachers are all trained the same at the start, it's the facilties and the morale that matter. Public schools can't refuse to hire teachers who are qualified to teach, just the same as they can't reject students living in the designated school zones. But teachers work better if they get better treatment and more respect, if they really like their jobs, or if their students are of better quality. Students of disavantaged families are already on the losing side because they don't have a nurturing environment before they even reach school ages. It's like a self feeding , vicious cycle. The bad start brings out bad harvest, bad harvest reduces revenue and provides less resources for the next season.
Most of our public schools suck because of inequality, that is the key element.