Strunk & White say: Put a comma before a conjunction that introduces an independent clause.
Okay, what does that mean?
Conjunctions are: and, but, or, so, yet…
What they’re saying is when you have a sentence and you’re joining it with a phrase that can stand on its own (independent clause, in italics), you put in a comma:
The bridge was rickety, so I had to tightly hang on to the rope.
“So I had…” could be a sentence by itself but for artistic reasons, I want it to be with “the bridge was…” and that’s why I toss in the comma…
I think. Sometimes grammar is just really confusing.