This is another one of those quirky grammar rules that trips people up. The key here is to remember that the apostrophe replaces missing letters.
It’s is the contraction for it is or it has. The apostrophe indicates to readers that letters are missing. Example: It’s windy. (It is windy.) It’s been warm today. (It has been warm today.)
If it’s can be replaced with it is or it has use an apostrophe.
Its shows possession. It is the possessive pronoun for it. Example: The cat loves its toy mouse. (The toy mouse belongs to the cat.)