I used to trip over this one constantly when drafting contracts and emails, especially under deadline pressure when your brain just freezes up. The trick that finally stuck with me was stopping to ask myself a simple question: can I replace the word with "it is"? If yes, use it's. If no, use its.
That's really it. "The dog wagged its tail" - you wouldn't say "the dog wagged it is tail," so its is correct. "It's raining" - you can expand that to "it is raining," so it's works. Once you internalize that one swap-test, the second-guessing usually stops because you've got an objective way to check yourself instead of relying on memory.
The other answers here make good points about the comparison to his or her, and that does help some people solidify it. But if you're the type who needs a mechanical way to verify, the expansion method removes all doubt in about two seconds.