Dogs bark at strangers as a form of communication. They may see unfamiliar people as a potential threat or danger to their territory or family, so they bark to alert their owners and to warn the strangers to keep their distance. In some cases, dogs may also bark out of fear or anxiety when encountering someone new.