Dogs bark at strangers as a form of communication to alert their owners of potential threats or to express their discomfort or anxiety around unfamiliar individuals. Barking is a natural instinct for dogs and is often used as a way to establish boundaries and protect their territory.