Rancidity is a very general term and in its most general meaning, it refers to the spoilage of a food in such a way that it becomes undesirable (and usually unsafe) for consumption. When people say that a food has "gone bad," what they're usually talking about is rancidity. Most of the time, but not always, rancidity can change the odors or flavors of a food in such a way that it becomes very unpleasant to smell or taste.
While most any food can technically become rancid, this term applies particularly to oils. Oils can be especially susceptible to rancidity because their chemistry can make them exceptionally susceptible to oxygen damage. When food scientists talk about rancidity, they are often talking about a specific type of rancidity involving oxygen damage to foods, and this type of rancidity is called "oxidative rancidity." During the process of oxidative rancidity, oxygen molecules interact with the structure of the oil and damage its natural structure in a way that can change its odor, its taste, and its safety for consumption.