Musical consonance and dissonance are the exact opposite of each other, like day and night. Though both refer to the type of sound achieved by playing a chord or interval, they produce radically different tonal types. Musical consonance is typically thought of as a pleasing or resolved sound; it is achieved by two notes that clearly complement each other and produce a comfortable chord or interval. Musical consonance is at the very heart of composition. Most songs consistently contain some level of musical consonance, whether perfect or imperfect (a classification coined during the common practice period); perfect musical consonance is found in perfect fourths and fifths, octaves or unisons, and imperfect musical consonance is found in major or minor thirds or sixths.
Musical dissonance, on the other hand, is a chord or interval that seems restless or uncomfortable. It can be achieved by playing a chord that doesn’t resolve the song, or two notes that very audibly clash with each other, such as minor seconds or major sevenths (usually notes that lie only a half-step away from each other). The concept of musical dissonance isn’t necessarily universal, however; what one era considered to be a musical dissonance is sometimes considered to be a musical consonance in modern times (for example, perfect fourths were at one time seen as dissonant). And in some eras, musical dissonance was even forbidden, all songs had to be resolved; this was an era in which perfect fourths and fifths were some of the only acceptable chords. In modern music composition, however, musical dissonance is not only allowed, it’s often encouraged. Rock musicians use dissonant chords like minor seconds and tritones to great effect and even classical composers employ musical dissonance to create a dark, specific mood.
In a sense, all music can be viewed as a contest between dissonance and consonance. If a piece of music was all consonance, it would be boring. If it were all dissonance, it wouldn’t be listenable at all. So every piece of music is crafted in a unique way to move back and forth between those two extremes to create both interest and pleasure.