What are bag searches for?

Clearly they don't object to food & drink at most theatres, but the searches are often so swift & half-hearted (only main backpack compartment, no lifting up of contents, I even had staff just literally pat down my bag from the outside. So I don't feel like harmful devices etc would be detected, unless they're massive. I also often use the deep pockets of my coat to store stuff & they don't pay attention to that at all. Don't get me wrong - I don't mind the searches at all & an extra layer of security is always welcome, but to me this often seems like a very random thing? Can someone enlighten me?