This apostrophe replaces the missing letter or letters and joins the words together to make one word.

I am → I'm

I am → knock off the 'a' → join the 'm' to the I with an apostrophe → I'm.