My department fielded a pretty robust SRO program after we had an incident with an armed intruder in an elementary school several years ago. If I recall the admin details correctly, the school district foots the bills for the officers and their supervising sergeant.
Having a uniformed officer in the school teaches the students to look to the police to protect them. They will come to expect the police to protect them when they leave school as well. If every other person is a police officer will that be enough? Three fourths?
Well, the mission statement for most every police department in the nation centers on protecting and serving the community. While having officers (or other armed security) on the ground in the school system does make the school a harder target, I don't think most students day-to-day think about the SROs being there to protect them from active shooter scenarios (though obviously at the moment that may be exactly what a lot of kids think about).
What SROs mostly do day to day is community policing in a school environement -- kids see the same couple faces day after day, the SROs develop rapport with the population they serve, and end up doing more active law enforcement (which may or may not actually involve charges and the juvenile justice system) when one kid steals another kid's iPhone, kids physically assault one another, somebody bring small or large quantities of drugs onto school property, etc. That rapport and accessibility also makes them frequent first points of contact for kids coming forward about abuse at home, domestic violence or sexual assaults involving romantic relationships they are in, and other major crimes involving students as victims or witnesses occurring outside the school itself.
Finally, the SROs fill in a big gap in the intel equation being boots on the ground around the kids who fancy themselves gangstas or are otherwise going off the rails in a big way. Info they develop in day to day interactions with the teenage population helps pretty frequently with identification or location of juvenile suspects in everything from vandalism to homicide cases. (And older ones, too -- I can think of at least one case where an SRO recalled a real scumbag and his friends and hangouts from his high school years well enough that it led to his being located when he was back out of his first stint in prison, in his mid 20s now, and running amok on some drug thing.)
It's honestly a better arrangement for community/police relations than striving to do similar sorts of community policing efforts in the community as a whole manage ("more with less" business models for local and state level LE and other agencies/services don't allow for a lot of bridge building and bonding with the community, even though that's the general goal of all local LE agencies these days).