In addition, actual funding for the schools comes mainly from property taxes at the local level. Only about 5% comes from federal money and 30-50% from the state. However, the local money is not distributed among different localities to equalize things. The property taxes are based on home values, which means neighboring districts can have vastly different budgets per pupil. Rural districts often far the worst.
In addition, the amount of property tax given to the schools is determined by the voters in most localities. Even a $10 a year hike in property taxes must be approved by 50% of voters. Shockingly, it's easier to get such tax levies passed in more affluent communities, where it's more affordable. In the less affluent communities, it's not uncommon for there to be bake sales and the like to get money to pay for advertising to convince voters. This means that budgets can vary significantly from one year to the next, meaning teaching jobs and therefore class sizes fluctuate.
To give you an idea of how much things can differ from state-to-state, I teach high school math in the state of Washington (not to be confused with Washington D.C.).
The state of Washington has in its state constitution that "ample funding" for "basic education" by the state is the state's "paramount duty". Because of this, the state has taken it upon themselves to try to do the majority of the funding for the schools within the state. While Kirian cites that approximately 30-50% of the money comes from the state, in Washington State, that number approaches 75%.
Many parts of what individual local districts can do is limited by this state regulation. For instance, local districts can raise funds, but the state has explicitly limited how much can be raised by local levy, as well as what can be done with it. Since the state's current functional definition of basic education includes just five classes per day at the high school level, local levies often end up paying for the district's ability to offer a sixth class per day, and in some cases (but not many), a seventh.
Also, because the state considers it their duty to provide for basic education, salaries are set at the state level. Because local levy money is limited in terms of the total dollars that can be raised and since most of it is used for providing additional classes per day (and accordingly, hiring the extra staff required to offer these classes), local levy dollars often don't significantly add to this total. Local levy dollars are only allowed to be added to teacher salaries for TRI pay, where TRI is comprised of Time (you were required to spend more time, perhaps at trainings), Responsibility (you took on added responsibilities), and Incentive. The Incentive dollars are light, because the districts don't have the funds to offer them, by and large.
While Kirian describes a system where the most affluent districts are best off financially, the reverse tends to happen to some degree in Washington state: because the cost-of-living in or near affluent districts is so high, but school districts in those areas can't offer a proportionally comparable salary, affluent districts often become training grounds for newer and younger teachers before folks move on to districts closer to home. I teach in one of the more affluent districts in the state, live 45 minutes away in good traffic, and make 10% more than I would working for the high school five minutes from my house. This is my 11th year teaching in that district, and at age 35, I have been the most senior member of the math department in my particular high school for six consecutive years now.
Kirian mentioned class sizes, and mine operates at an average of 34 students per class, where I teach five classes per day. The more advanced classes tend to be larger so that we can focus more individual attention on the struggling students. That seems to be more of a district-level decision than a state-level decision.