When you cough up mucus, your body may be trying to get rid of an infection or another respiratory disease. Although it might not always indicate that you are getting better, it is frequently an indication that your body is fending off the disease.