Brewed coffee doesn't spoil or become dangerous to drink after a while. But depending on the coffee drinker's standards, coffee may go "bad" in terms of a stale or funny taste.
Coffee beans contain oils that can become rancid after a while. Make sure to use the beans within three months so that the coffee tastes fresh. To keep coffee beans fresh longer, freeze them. Once coffee is exposed to oxygen, its shelf life becomes shorter as the days go by. Ground coffee goes stale faster than whole coffee beans because the grounds have more surface area exposed to oxygen. It makes good sense to store ground coffee in an airtight container.