I disagree that, as a consultant, one's role is to simply shut up and do as you're told. I take the view that I am being hired for my expertise and to just keep my opinions to myself rather than freely offering that expertise would be a disservice.
When my clients request that I do something I disagree with (or something I simply don't want to do), I lay out my reasons, ask about why they want to do what they asked in the way they specified, and try to explain why my way would be the better option. It's also important to make it very clear to them that you'll gladly do it their way if that's still what they want after reviewing your arguments1, of course. My clients respect this and I have the distinct impression that it is one of the major reasons why my repeat customers keep coming back.
1 Provided that's true. One case that comes to mind is someone who wanted an application created which not only violated a third-party website's ToS, but also had a large degree of complexity specced which was clearly intended solely to bypass that site's attempts to enforce their ToS. When they displayed a lack of interest in looking for ways to obtain their data in a ToS-compliant manner, I said "I'm not comfortable with doing this project" and walked away.