In healthy people, ears pretty well take care of themselves. The most delicate parts are sheltered by the structure of the head. Ears produce wax, which protects the inner workings of the ear and the eardrum from dust and dirt particles. This wax then moves out of the ear, taking any dirt or dust with it.
Sometimes a virus or bacteria gets into the ear and this infection causes ear pain. This is particularly likely to happen when you already have a cold or other respiratory illness. Fluid can also back up in the middle ear canal (called the Eustachian tube), blocking the tube and providing a place for bacterial to grow and flourish.