Coffee has two enemies: humidity and oxygen. Keeping it away from those two is the best way to preserve its characteristics.
Humidity: coffee is higroscopic. This means that it absorbs moisture very fast. If you want to verify this, simply put a bit of ground coffee in a plate on your counter. In a couple of hours it will look "bigger" because the moisture that it is absorbing will increase the volume of the grinds.
Oxygen: the minute we roast coffee it starts to oxydize and lose the good properties of aroma and flavor. To preserve them, you must minimize coffee's contact with oxygen in order to slow down that reaction. that is why good coffee is always packaged in a foil bag with a fresh valve, the whole that allows gas to go out and no oxygen in.
So,the key to keep coffee in good shape and tasting great is to make sure it is in a tightly sealed container, in a dry place. This is specially important if your coffee is already ground.