There are certainly many opportunities to self-publish your work and avoid taking on either an agent or a publisher. Taking this route, however, means that you carry the entire responsibility of marketing your work. I’ve done this, it takes lots of time, and while I’m a highly competent writer, I don’t market books well.
Where does an agent fit into this? Publishers typically do not want to look at first-time authors who don’t have the name recognition that will help them to ensure sales. Agents do the work of separating those who have a saleable story from the rest. A good agent will know what publishers are looking for and can provide some assessment of how your work fits in. A great agent will help you determine what changes you might need to make to become more saleable.
Without someone in your corner with industry experience, you’re trying to figure everything out on your own. For many writers, it’s a question of whether you want to spend your time writing or donning the many hats you’ll have to wear to sell your manuscript.
I’ve self-published a novel. If I could jump into the DeLorean and do it over, I would attempt the traditional route before self-publishing. Why? Because it’s a better test of the strengths of my manuscript.