In simplistic terms, the importance of having an agent boils down to this: while some publishers will accept unsolicited manuscripts, others will not. If not, your only option is to be recommended by an agent. Of course even those that do accept unsolicited manuscripts are far more likely to give your story the time of day if an agent put it forward. Therefore having an agent is pretty much crucial if you want the attention of the big boys.
Agents however are just as difficult to get represented by as a publisher. It is much the same in illustration, where it is as hard to entice an agent to represent you, as it is to find a job on your own. Much as a publisher would, an agent will look through the manuscripts they have been sent and choose those with promise to put forward to their contacts.
Contacts are always the key thing you get with any agent no matter what industry you’re in. They already have the keys to all the doors you can’t even get your foot in, they know all the right people, the ones you need to know to get stuff done, and they know about publishing; they know what the publishers want, and how to approach them.
From what I learnt over the course of the book festival anyone looking to get a mainstream book published should be approaching agents first.