Hi Yoast
I agree with the other posters.
The famous English scientist invented a machine which would tell you at once, without you(r) having to open / you(r) opening the wrapper of a bar of chocolate, whether or not there was a Golden Ticket hidden underneath it/that wrapper of a bar of chocolate."
If the wrapper were a subject, it would come before a verb. It doesn't. It comes after a verbal, which makes it an object. That's its function, as 2006 rightly points out; e.g., open <something>.
Its form: it's a noun phrase modified by the prepositional phrase of a bar of chocolate.
The pronoun it refers back to the entire noun phrase the wrapper of a bar of chocolate. That is, the Golden ticket is underneath the wrapper--of a bar of chocolate, as opposed to, say, the wrapper--of a stick of gum.
Hope that helps.