What’s the purpose of the flap on the side pocket?

It’s there to prevent items you’re carrying in the pocket (such as a phone or tactical tools) from falling out while you’re engaged in physical activities.