minor chords

Much of our music, from classical to contemporary, is written in either a major or minor key (with exceptions, such as jazz, which uses neither). For most, a major key conjures up feelings of happiness, while pieces written in a minor usually do the opposite. Is this merely a function of learned behavior, or is there something else going on?