Most schools these days insist on wholesome, healthy food, and unfortunately, nearly all sweets contain a lot of sugar, which is bad for teeth.
Having said that, my autistic son has difficulty in eating a variety of food, so I was advised by his doctor to pop a couple of fudge fingers into his lunchbox. it's not ideal, but keeps any hunger at bay until he gets home, and the school allows this.
In the case of children with no special needs, I'd have to agree with the school's ruling though. The lolly might be alright in itself, but then you'd see other sweetstuff being brought in by the pupils, and it'd all be back to square one.