Vending machines are not cheap. They cost thousands of dollars ($) to purchase and maintain. The machines cost hundreds of dollars ($) to keep fully stocked. In total, over 1 year a business or a school, depending on how many people use that machine could spend thousands of dollars ($) to keep up and running. So a school to keep vending machines would mean that about 800 hundred students would have to buy at least one item over that year.
With all that being said, the machines require an immense amount of customers to turn a profit. If you spend 1,000$ a year on food for the machines, you just need roughly 1,000 people to buy something 1$ or more right? However if 600 students buy something but the machine runs out after 250 students then what do you do? Give them a free lunch? No, the schools will have to either refund them, or give them free lunches or something. Thus causing a huge amount of issues for the schools. The last thing the superintendent of the school district wants to have coming to his office is an angry mob of parents ready to sue the schools for not refunding the students or inputting more machines.
So even though you may be able to think up a ton of reasons why the machines are bad, just remember where there are cons, there are always some pros. Vending machines can potentially generate some revenue for businesses and schools. The machines could provide more options for the students or employees. The options could be healthier things, such as Clif Bars or some granola bars or something. Those are just two pros but there will always be pros in someway, shape or form. They always exist, no matter what.