One is a pre-filter. The other is the fine particle filter.
The one closest to the engine is the fine particle filter (usually 2 micron). The other filter (pre-filter) usually filters down to 10 or 12 micron.
For no more than they cost, you should always replace both.
The purpose is just to keep the fine particle filter from clogging so quickly.