The main reason why dogs bark in their sleep is because they have dreams just like humans do.
Dogs go through a dream stage of the sleep cycle every time they go to sleep.
It is during this stage of sleep that your dog is likely to bark or make other noises such as growling or whimpering.