It's not wrong; it's perfectly grammatical. "It's" is just the contracted form of "it is" and "it has". Who told you it was wrong?
By contrast, "its" (without the apostrophe) is a genitive case (possessive) pronoun typically used to indicate possession, as in "The dog has lost its collar".