text: It is instinct for male dogs. They mark territory by peeing on things and lifting their legs in such a way enables them to piss higher on the object they piss on so the next dog (or other animal with good scent) that passes will think they're in the territory of a bigger dog. This is also why they generally pee on objects like trees or the classic fire hydrant, you can't display height or size if it all ends up on the ground.