There are some things a dog cannot help doing. If he is going to bite someone, he needs to look at his target, and he needs to bare his teeth. If he is going to defend himself, he has to tuck his ears back and his tail down and turn aside. In the dark unrecorded mists of wolf history, wolves that had the wits to notice these things had an edge over their more obtuse pack-mates. Being on the lookout for the fangs or the intent stare of a more powerful member of the pack was a way to avoid unnecessary physical injury from a wolf one had no intention of challenging anyway; being on the lookout for the cringe or the averted gaze of a weaker member was a way to avoid the unnecessary trouble and danger of fighting with a wolf who was prepared to give way without a fight anyway.
Once wolves were on the lookout for unintentionally dropped hints, it became possible to start dropping them intentionally. A wolf that can accurately read a fang or a stare as a threat can avoid a fight and a wolf that can show a fang or fix a stare can then express a threat without a fight. This evolutionary feedback loop between receivers and senders is what was almost surely behind the development and rituals of the visual signals that wolves, and now dogs, use.
Most of these signals are directly related to the very serious wolf business of dominance and submission within the pack. Dominance and threatening signals include baring the teeth, pricking the ears, and staring. Submissive and nonthreatening signals include laying the ears back, averting the gaze, approaching obliquely rather than head on, tucking the tail tightly under the belly, and (the ultimate gesture of passive surrender to superior force) rolling over and lying belly-up. Over sufficiently long time, these signals become ritualized. Every time a wolf lifts his lips and shows his fangs, he is not literally about to bite; rather this is a symbol of threatening intentions, and, at this point in the evolutionary history of the wolf, read as such by other wolves. Wolves are predisposed to read it that way because of the indisputable fact of evolutionary history that fangs really do bite. Wolves became in turn disposed to use a show of fangs as a threatening gesture precisely because wolves were predisposed to react to fangs as a threat.
Just about all vertebrate animals long ago acquired an innate appreciation of another biological fact that is frequently exploited in visual communication: big things out there are more dangerous than small things. Thus threatening or dominance-asserting wolves try to literally look big. They stand erect, sometimes astride the animal they are attempting to impress, they raise their tails, they stiffen their hackles.
Submissive or fearful dogs try to look small by crouching low, sometimes even dragging themselves along the ground. It is important to realize that this does not mean that the big- looking wolf is conscious of how big he looks, nor that any other wolf is fooled into thinking he really is big. Again, these are rituals. But they ultimately derive from the fact that wolves have been wired to react in ways that make these rituals effective.