A bad smell coming from food is a warning that something is wrong with it and you shouldn't eat it. A musty smell coming from your bathroom is also a warning. It's a signal that you need to make some changes to the room and to your showering routine.

...
Mold and mildew can make your bathroom smell earthy and unpleasant.

Musty Smell

The musty smell in your bathroom is caused by mold or mildew. These fungal growths cause the same musty odor in damp basements. They thrive in moist, poorly-ventilated areas, especially in bathrooms. Follow your nose to find the mold. Common locations for growth include inside the shower, on walls behind towels or picture frames or on the ceiling. Mold and mildew are typically dark colored and grow in feathery-looking patches.

Issues

You can't ignore mold and mildew in your bathroom. Not only is the musty smell unpleasant, but it can be hazardous to your health. People who are sensitive to mold experience headaches, nosebleeds, respiratory problems and nausea when exposed to mold spores. Mildew can stain grout between tiles and damage paint. Over time, it can eat into drywall and spread throughout your home, which can lead to serious damage and health problems over time, requiring intensive work to remove.

Solutions

Getting rid of the fungus in your bathroom will take care of the musty smell. If mold is growing on tile or fiberglass, use a solution of 1 cup of bleach in 1 gallon water. Soak a sponge in the mixture, and wash away the mold. For mold growing on paint or wood, dilute the solution to 1/4 cup bleach in 1 gallon of water. Once the mold is washed away, dry the area as quickly as possible. If you have mold growing in a patch larger than one square foot, contact professionals to remove it and evaluate the damage left behind.

Considerations

If you don't make any changes to your bathroom, mold and its musty smell will return. Install an exhaust fan and run it while showering to pull excess moisture from the air and make the room less hospitable to mildew. Keep a squeegee in the shower, and use it to wipe down the walls and shower curtain after each use to prevent mold growth in the shower. Always hang wet towels so they dry more quickly; leaving them crumbled on the floor can lead to mold growth on the fabric.