The greatest advantage you can have when selling your home is having a complete understanding of the condition of your property in advance of the listing process. Having a home inspection prior to going on the market is an ideal way to avoid surprises and unexpected, costly repairs that can put you at a disadvantage at the negotiating table.
A couple of examples:
A potential buyer's home inspection report comes back with minor repairs like unsealed windows or a broken seal on the toilet floor. If these items become part of the negotiation, you may have to fix them at your own expense - and you'll have to call in a licensed professional to do it. But if you had that report ahead of time, you could fix some of those things yourself, or have cousin Joe who's super handy come by and do it on the cheap.
On the opposite side of the spectrum, say your inspection reveals a really terrible foundation problem. In advance of listing your property, you can make decisions about whether it makes sense to repair the problem before the sale or list "as is." Do you repair the foundation and hopefully recoup costs with a higher listing price? Or let the next owner worry about it and list for less? Either way, it should be your decision.