This is a complex question with a lot of variables.
- How bad is it, really (all codebases seem bad when you first inherit them.).
- How good can you make it?
- How long is it going to be around? (it has to be around long enough to get the return back on the rewrite)
- How likely is it that there are terrible security problems that are difficult or impossible to fix in the current rev (it only takes one massive security hole to sink a project).
- How bent out of shape will the person who wrote the code get?
- How much power do they wield in the organization?
- How responsible are you for the project?
- How long will you be involved?
- How many developers are there who are comfortable with the current codebase?
- Will fixing it require new technologies/frameworks/tools?
- How flexible is your management in allowing for this type of work?
Bottom line, -is it best for the customer-.
In my younger days, I always wanted to change thing, but I've developed a healthy respect for running, working, production code. There is value in that. Unless there's a clear win, it's a waste to rewrite it. Be objective, stack the pros and cons, and make your case. It's best if you can make the decision collaboratively. If you give the other person chance to have some ownership as well, and don't attack it unnecessarily, they will often be more than happy to admit it's not the best code.
Also, your vision of the right way may differ from theirs.
Think of it like redecorating. If you're visiting a friend for a weekend and staying in their guest room, it would be insane to repaint, change the bedding, and hang new drapes, no matter how much you hated them. It would be a waste of effort, and they'd be insulted and confused. If you were staying for 6 months, you might very well want to have that conversation though. And of course if it's your house you're moving into for 5-6 years, you'd have no qualms about knocking down a few walls or expanding the kitchen, no matter what the previous owner thought.
In the end though, never rewrite the thing wholesale. Do it piecemeal, bit by bit, and move to what you want after dealing with day to day problems for a while. By dealing with the day to day issues with the current codebase you learn about what sorts of things you need to handle, and plan accordingly. Customers -hate- the "sorry, no new features for this release" unless things have gotten so bad that the app is actually unstable and they notice the problems.