Domestic dogs learned to bark from being with humans.

Domestic dogs have one key difference from their wild counterparts, they bark. 

They not only bark, but they bark in certain acoustic ways for various purposes whether for alarm or play. 

Researchers believe this occurred over thousands of years by evolving to human requirements.