Using mediation to negotiate a divorce agreement is almost always going to take less time, cost less, and result in a more solid agreement than using a lawyer to take the same case through the courts. When you are going to have an ongoing relationship with your ex-spouse, such as when you have kids together, mediation can help to improve communication and make your future interactions a little bit easier.
For some couples, however, negotiating directly with each other, even with the help of a mediator, is not possible -- either because of problems in the relationship (such as domestic violence or substance abuse) or because a spouse is unwilling to mediate. Even if you decide to mediate, you may want to hire a lawyer in a limited capacity to consult with you outside of the mediation. Many mediating spouses find it helpful to work with a consulting lawyer who can offer legal advice and review the settlement agreement before it is signed.
For more guidance on when mediation is the best choice, see Will Divorce Mediation Work for You?