While writing a melody over a bass line, it is generally advised to have the melody & the bass line moving in contrary motion to each other. I want to know if such a rule also exists when you write for SATB. Do the Soprano & Bass have to move contrary to each other, just like the melody & bass line?
I'm reminded of that quote from the US version of The Office: "What's the safest way to go skiing? Don't ski!"
The rule suggesting contrary motion isn't because there's anything inherently better about contrary motion. Rather, it's that contrary motion is a means to an end in preventing forbidden parallels like parallel perfect fifths and octaves. Contrary motion isn't required; if you don't have contrary motion and you're not breaking any part-writing rules, then your voice leading is fine.
Although you do not have to have contrary motion at all times, there will be occasions when you need contrary motion between the soprano and the bass. Let's say you're moving V to vi and the soprano has scale-degree 2 above the V chord. This soprano can't move to scale-degree 3, because that would be parallel perfect fifths with the bass. As such, you need to move the soprano down to scale-degree 1 in contrary motion to the bass.
But instead of memorizing all similar instances where this would be the case, it's much much easier to just watch for and prevent forbidden parallels.
The accepted answer is only partially right. The main purpose of contrary motion is not the prevention of parallels, although that is a well-known positive side-effect.
The main purpose is to create the impression of independence of individual voice lines. The original idea behind an aversion of parallel octaces and fifths is also exactly that.
Independence here means that the individual lines are being perceived as being distinguishable voices, entities for themselves - as opposed to merging into one big sound.
If you understand this, counterpoint ceases to be an application of old-fashion rules and becomes a tool to achieve certain sonic perceptions.
To further understand this idea, you have to understand the aesthetic ideals in the musical epoch in which these guidelines emerged: the renaissance.
During that period - and during that period alone - the highest goal of polyphonic music was to have a perfect balance between each voice so that none of the voices would start to become too „ear catchy“ as opposed to others.
Later musical periods didn‘t want or didn‘t emphasise this auditive balance between all the voices.
Hence, regardless of musical style, you can apply these counterpuntal principles whenever you wish to make multiple voice work with each other and have them distinguishable.
On the other hand, you can break these rules whenever you wish the sounds to „blend“ into one bigger sound.
Same as 2 part writing really. Contrary motion between the outside parts is the extreme opposite of naughty consecutives! (I'm not saying that parallel motion WILL always cause consecutives!) You don't have to do it ALL the time. But it's useful when a 'full' harmony is the aim. (But remember, you don't always want to sound like a 19th century hymn tune).
As always, when discussing traditional SATB writing, consult the Bach chorales. You'll see that there is both contrary and parallel motion between the outside parts. Contrary motion isn't a 'rule'. It isn't even 'generally advised'. But if the aim is to write independent parts, it's good if they don't always follow each other in parallel.
Contrary motions in harmony exercises are good because they remove the chance for parallel fifths and octaves to a great degree. Off course you can have passages move in parallel but you need to be sure you don't commit the offense of parallel 5ths / octaves.
Generally having your voices move in parallel is a bit more of an advanced way of doing harmony, not impossible, it is just if you want to get the newbies over the hump of learning the basics it is often just easier to tell them to avoid it.