You'll gain experience as you move through the world by exploring Pokéstops and battling at Gyms. With the first five levels, your trainer unlocks access to higher quality Pokéballs. In addition to this, Niantic has said that higher trainer levels are more effective when it comes to battling at Gyms. The higher your level, the easier time you're going to have. If you have a higher level than the trainer, or trainers, who left a Pokémon at the Gym you've got a better chance of taking it over. This is especially true when it comes to fighting multiple trainers to take over a single Gym.