Neither of these sentences makes sense:
"Who's hat is it?" Means "Who is hat is it?"
Instead of using apostrophes, the English language has possessive versions of who and it:
Whose hat is it?
Think of the words his and hers. Both end in s, but have no apostrophe. These are examples of possessive pronouns.