Dogs cough for the same reasons as humans; to get rid of dust particles or other irritants in their airways. A persistent cough is usually a sign of illness.
If the cough is a ‘honking’ cough, then your dog probably has kennel cough. This will usually clear up by itself and isn’t a worry as long as your dog is still eating and drinking plenty. If the cough persists for longer than a week you should take your dog to the vet.