I've been intending for a while to write about Hume's too-often-neglected philosophical account of good manners. So here it goes.
The key to Hume's account is sympathy, which produces our sentiment of morals in all the artificial virtues (Treatise 3.3.1.10). Artificial virteus are virteus only because they have a tendency to social good (they are 'artificial' virtues precisely in that they are invented for this purpose, or, at least, come to be generally approved for this reason). Hume gives a number of examples of these artificial virtues: (property-)justice, allegiance, modesty, chastity, 'laws of nations', and good manners.
So how does sympathy create the virtue of good breeding? Consider the case of someone arrogant. Through sympathy we enter into how the arrogant man feels about himself. These feelings present a view of ourselves that is "mortifying and disagreeable" (Treatise 3.3.2.6) - in short, humiliating. Needless to say, we don't like this at all. And since everyone feels this way about arrogant or proud people, everyone disapproves of arrogance or pride (ironically, because we are to some extent proud ourselves and don't like feeling humiliated). On Hume's account, this suffices to make pride a vice. To restrain this vice, we begin to develop general maxims for behavior. Enter the rules of good breeding.
Hume makes an analogy between the rules of good breeding and his account of the laws of nature (by which he means general maxims about just property-transference):
Laws of Nature
negative function: to prevent opposition of self-interest
positive function: to secure property in society
Rules of Good-Breeding
negative function: to prevent opposition of pride
positive function: to render conversation agreeable & inoffensive
So etiquette serves a function analogous to property law: it reduces conflicts between people and makes their lives easier.
Now, Hume regards the distaste for pride that grounds etiquette as a prejudice, and so we find that Hume's account of good manners draws almost directly from the discussion of prejudice as a form of unphilosophical probability in Treatise 1.3.13. And if we turn back to that section, what do we discover? Hume uses the rules of manners as an example in his discussion of unphilosophical probability:
For why do we blame all gross and injurious language, unless it be, because we esteem it contrary to good breeding and humanity? And why is it contrary, unless it be more shocking than any delicate satire? The rules of good breeding condemn whatever is openly disobliging, and gives a sensible pain and confusion to those, with whom we converse. After this is once established, abusive language is universally blam'd, and gives less pain upon account of its coarseness and incivility, which render the person despicable, that employs it. It becomes less disagreeable, merely because originally it is more so; and 'tis more disagreeable, because it affords an inference by general and common rules, that are palpable and undeniable. (Treatise 1.3.13.14)
So when someone acts toward us with scurrility, e.g., insulting us horribly, this shows up against the background of the rules of good-breeding, and are condemned because of these rules, which have been developed to keep pride in check. These rules also, interestingly, mollify the insulted: because they exist, the person insulted can regard the insulter as 'despicable' - "no good breeding in that one" - and this means that the insulter's opinion (as expressed in the insult) is really much less important than it might have otherwise seemed. What is happening in this case, according to Hume, is that our reasoned judgment has joined forces with our prejudice against self-applause. This prejudice would operate even contrary to reason, but, of course, not all prejudices are contrary to reason all the time.
This gives us something of a picture of how the rules of etiquette build up. We develop our (somewhat, and Hume thinks necessarily, inconsistent) prejudice against self-applause. But prejudices on their own can be very irregular and inconstant, as well as undiscriminating. Prejudices lead us into contradictions. To resolve these contradictions we reject or refine the first crude principles encapsulated in our prejudice. And so it goes. Of this sort of pattern, Hume says:
Mean while the sceptics may here have the pleasure of observing a new and signal contradiction in our reason, and of seeing all philosophy ready to be subverted by a principle of human nature, and again sav'd by a new direction of the very same principle. The following of general rules is a very unphilosophical species of probability; and yet 'tis only by following them that we can correct this, and all other unphilosophical probabilities. (1.3.13.11)
This is not a minor point; for all philosophy and science is built on general rules! But as noted above, not all such general rules are equal: some are more regular than others, in the sense that they lead us into fewer contradictions. The more regular they are the more they are considered 'rational'; the less regular are, the less 'rational' they are considered to be. In reality, they are the same sorts of things; it's just that, as a matter of practice, we find some more useful than others because they fit our experience more easily. The rules of etiquette, despite their origin in the prejudice against self-applause, are clearly considered by Hume to be refined enough to be considered 'judgment', i.e., rational. Our rejection of pride is a hastily and rashly formed general rule; but refinements on this general rule improve it for the purposes of society. It always remains a prejudice - Hume likes to argue that it really can't be a vice for someone of genuine merit to value himself highly - but genuinely serious forms of pride are common enough that we don't make any exceptions for them. And just as the rules of etiquette allow us to insult people if we do so in an oblique and subtle way (we call these 'witticisms'), so they allow people to disclose their superiority, if they do so in a sufficiently oblique and subtle way:
Nothing is more disagreeable than a man's over-weaning conceit of himself: Every one almost has a strong propensity to this vice: No one can well distinguish in himself betwixt the vice and virtue, or be certain, that his esteem of his own merit is well-founded: For these reasons, all direct expressions of this passion are condemn'd; nor do we make any exception to this rule in favour of men of sense and merit. They are not allow'd to do themselves justice openly, in words, no more than other people; and even if they show a reserve and secret doubt in doing themselves justice in their own thoughts, they will be more applauded. That impertinent, and almost universal propensity of men, to over-value themselves, has given us such a prejudice against self-applause, that we are apt to condemn it, by a general rule, wherever we meet with it; and `tis with some difficulty we give a privilege to men of sense, even in their most secret thoughts. At least, it must be own'd, that some disguise in this particular is absolutely requisite; and that if we harbour pride in our breasts, we must carry a fair outside, and have the appearance of modesty and mutual deference in all our conduct and behaviour. We must, on every occasion, be ready to prefer others to ourselves; to treat them with a kind of deference, even tho' they be our equals; to seem always the lowest and least in the company, where we are not very much distinguish'd above them: And if we observe these rules in our conduct, men will have more indulgence for our secret sentiments, when we discover them in an oblique manner. (Treatise 3.3.2.10)
This is all the Treatise account. The Enquiry account is shorter but much the same; he even draws the same analogy between rules of good-breeding and rules of justice. He calls these rules of good-breeding a "lesser morality" and, in another place, "the companionable virtues."
One other place in which Hume discusses the philosophical underpinnings of good manners is the essay "Of the Rise and Progress of the Arts and Sciences." There he argues that republics and monarchies create different sorts of cultural climates, because advancement depends on different things in each. In republics advancement depends on usefulness; thus, Hume claims, republics are more conducive to the sciences. In monarchies, however, advancement depends more on being agreeable; thus they are more conducive to "the polite arts". It is in this context that Hume gives his misguided defense of gallantry. The basic point of the argument is right - that gallantry is an improvement over the previous condition. However, in arguing for this conclusion, Hume overshoots the mark by arguing that gallantry is virtuous and sits well with wisdom and justice. And I think in some sense he must. The rules of good-breeding may be a lesser morality, but on Hume's account they must be considered a morality; gallantry must be considered a virtue.
It is here, I think, that we start seeing the problems with Hume's philosophical account of good-breeding. It is, for one, an elaborate form of hypocrisy: we disguise our contempt and our arrogance largely so we can express our contempt and arrogance without being too offended by the contempt and arrogance of others. But at the same time, Hume's account makes this moral in a very robust sense. It may not be as important in the greater scheme of things as (say) justice; but it is for all that as much a part of morality as justice. Hume's account doesn't really give us much room for transcending the rules of good-breeding; we can refine them, but all refinement really does is give us more flexible versions of the same thing. Women are doomed to be inferior because that's the way the rules have always been; these rules are refined through the centuries, but all we ever can get is a less brutal way for women to be inferior! Much of this actually indicates more of a flaw in Hume's account of what virtue and vice are than anything in the actual account of manners, but not all of it. Still, it is arguably the most sophisticated philosophical discussion of manners or etiquette ever put forward, and is worth some thought despite its many and definite flaws.