The human ear consists of the outer ear, your middle ear, and your inner ear which is fairly deep inside of your head. The middle ear is separated from the outer ear by the eardrum (or "tympanic membrane" in medical terms). So, the air trapped inside the middle ear doesn't come in contact with the air outside of your head. When you experience a change in air pressure by getting closer to or further from the ground, your ears will occasionally "pop" to adjust the pressure of the air that is caught in your middle ear so that it matches the air pressure outside of your head. This is done by quickly opening the Eustachian tubes (which connect the middle ear to the back of the nose) in order to let air rush in or out of the middle ear as needed.
The most common place for someone's ears to "pop" is on an airplane, but it can also happen with smaller changes in altitude (the height above the Earth's surface), like when you are driving up or down a mountain. The air closer to sea level is at a higher pressure since it is being compressed by the weight of all of the air above it. As you climb to higher and higher altitudes, the air pressure decreases.
Some people may find the popping of their ears to be annoying, but if your body didn't do this, then the pressure on one side of the eardrum would be higher than on the other side which could bend your eardrum slightly and compromise your hearing.
If your plane is taking off, then you are going to an area with lower pressure so the high-pressure air in your middle ear will push outwards on the eardrum. When your ears pop, air rushes out. If you are coming in for a landing, then you have low-pressure air in your head (from when you were at a high altitude) and high-pressure air outside pushing inwards on your eardrum. When your ears pop, air rushes in.
One way to make this pressure equalization more comfortable is to do it yourself by swallowing or yawning frequently rather than waiting for your ears to pop by themselves. These methods work because swallowing and yawning cause the Eustachian tubes to open briefly. This is why many people choose to chew gum when their plane is taking off or landing (chewing gum or sucking on a hard candy makes you swallow more than if your mouth were empty).
If someone has a blocked or oddly-shaped Eustachian tube, then their ear will fail to pop as their plane is landing. This creates a small vacuum in the middle ear. Fluid then rushes into the middle ear to increase the outward pressure until it equals the inward pressure from the surrounding high-pressure air.
Little Lion Experiment:
To see the effects of having a blocked Eustachian tube, obtain a small plastic cup and a bowl with a flat bottom. If possible, use a clear cup so the water will be easier to see. If you don't have a clear cup, then try adding food dye to the water in this experiment to it will be easier to see once it is inside of the cup. Fill the bowl with about an inch of water. Turn the empty plastic cup upside-down and squeeze it until it bends inwards. Place the bent cup in the water.
Being careful not to let the lip of the cup rise above the water level, slowly squeeze the creases in the cup outwards so that the cup returns to its original shape. By doing this, you are creating a small vacuum. So, the pressure inside the cup (which pushes outwards) is lower than the pressure outside of the cup (which pushes inwards), and this pressure difference is what pushes the water from the bowl into the cup until the two pressures are equalized.
As a side note, the same principles of air pressure explain how straws, turkey basters and a variety of other objects are able to move liquids against gravity.