its (without an apostrophe) is a possessive pronoun, like his or her, for nouns that don't have a defined gender. In contrast, it's (with an apostrophe) is the shortened form, or contraction, of it is or it has
It's is a contraction that should be used in place of "it is" in sentences. The apostrophe serves as a visual cue that a word has had a portion removed. On the other hand, it's without an apostrophe is the possessive term for nouns without gender, similar to "his" and "her."
It's actually quite easy to follow the rule: only use the apostrophe after a word when part of it has been deleted. For example, it's raining indicates that it is raining, and it's been warm implies that it has been warm. It is a contraction in the same way that she is for she is and can't for can.
But a few centuries ago, this rule wouldn't have been applicable.
Throughout the 17th century, this possessive form with an apostrophe was still very popular. It's likely because ‘it's’ was assuming a new role and displacing the contraction 'tis that the variant without the apostrophe didn't become prevalent until the 18th century. It was already here and was about to leave.
The possessive ‘it's’ is still used in hurried tweets and mattress company advertisements, but just because it was correct 300 years ago doesn't mean it still is today. Use it's just when you mean it is or it has for those of us who write and live in the present. And remove the apostrophe from all other places.