An intro to counterpoint
Counterpoint is a musical technique that combines two or more independent melody lines. It's one of the characteristic sounds of Western classical music. Bach wrote a ton of it.
https://www.youtube.com/watch?v=TOxeDw2xyCE
But counterpoint isn't always so complicated. Any song that has a vocal melody with a bassline underneath is an example of counterpoint. If you have ever sung "row row row your boat" in a round, that is also counterpoint.
In Western classical composition, counterpoint is governed by strict rules, but it is also possible to create it through improvisation or intuition. For example, in Dixieland jazz, the clarinet and trombone improvise counterpoint around the trumpet melody, as in this 1927 Louis Armstrong recording:
https://www.youtube.com/watch?v=xO3k-S_pqK4
In Western Europe, counterpoint was mostly improvised this way until just a few hundred years ago.
Counterpoint is easier to understand when you're familiar with the source material. This was obviously intended as a joke, but is still helpful as a listening example:
https://www.youtube.com/watch?v=y1isQlg6VGU
One easy way to create counterpoint is to find two songs that have the same chord progression, and sing them at the same time. For example, "My Way" and "Life On Mars" make nice counterpoint when sung simultaneously.
https://youtu.be/nW0ACEOEq6w?t=105
Bach and his contemporaries treated counterpoint as a kind of musical Sudoku, giving themselves difficult compositional problems to solve. For example, a crab canon is a melody that you accompany with itself in reverse.
https://www.youtube.com/watch?v=xUHQ2ybTejU
Paul McCartney based "Blackbird" on Bach's Bourrée in E minor. It's a counterpoint piece written for lute, but it's a well-known classical guitar piece too.
https://www.youtube.com/watch?v=BpWHJkEosAA
Last semester, a student asked, in counterpoint, do all the voices need to be in the same key? The answer is, not necessarily. In Béla Bartók's "Two Major Pentachords," the left hand part is in F-sharp major, and the right hand part is in C major. It's pretty weird!
https://www.youtube.com/watch?v=7tQYtCdMhqA
If you're looking for a more in-depth guide with lots of interesting audio examples, be sure to check out The Contemporary Musician's Guide to Counterpoint. Also, try out the Bach Google Doodle. Enter a melody and it will automatically generate a four-voice counterpoint around it. The results are uneven but sometimes sound great.
If you want to write your own counterpoint, a good starting point is to pick a mode like Dorian or Mixolydian and overdub yourself doing multiple layers of improvisation. You might be pleasantly surprised by the result.