Dogs like to assume your territory as their territory. Within the human world, there is a scent based alternative dog world. In that situation, dogs live lives in which upon the sight of one another, one dog may decide to assume a more submissive attitude or it may decide to assert itself instead. Alpha dogs are aggressive and determined to protect what is their own. As a part of this territorial and dominating rule of a dogs life, everything that a dog does, can influence its safety, having its physical needs met and having its social needs met when it is among other dogs.
This all relates to why a dog lifts its leg when it pees. When a dog pees, not only is he releasing waste products from his body, he is also releasing his own individual scent. A dogs urine has much to say about the dog to other dogs including size. There is scented and personalized information contained in the urine about the dog.
Effectively, the dog is leaving a sort of personal calling card that contains information such as age and sex. You may recognize when your male dog stops to sniff eagerly where other dogs urinate. On such a spot, it is the height of the pee spots on the surface which indicate the relative height of the dogs which have peed there. The dog, which is able to urinate at the highest spot, is probably the tallest dog who could potentially be the leader dog in a group of dogs based on his size and if the dog had an alpha personality.
Dogs marking their territory on the fire hydrant have to lift their leg high to hit a vertical surface. Unlike female dogs, which pee on the horizontal ground, most adult male dogs choose to pee on vertical surfaces. When a dog lifts its legs, it has a better chance of hitting the community doggy calling card rack or fire hydrant that the local dogs use to announce themselves to one another.
The dog is able to balance itself on three legs while holding one leg in the air as it urinates. Not all adult male dogs lift their leg when peeing because of age, ability and desire. The same dog may lift its leg higher depending on whether the pee spot is in its own domain or in a public place.