What does "wherein" mean exactly?

Solution 1:

'Wherein' is generally only used in formal writing. The Oxford English Dictionary gives the following senses and quotes. I have given the most recent quote, from which you can tell that the word is no longer generally used.

  1. In what (thing, matter, respect, etc.)?

    1891 - Oh, Britannicus! wherein have we offended?

  2. In which (place, material thing, writing, etc.)?

    1888 - Peering keenly into the shadow wherein she stood

  3. In, at, during, or in the course of which (time).

    1819 - Length of days Wherein to act the deeds which are the stewards Of their revenue.

  4. In which (matter, fact, action, condition, etc.); in respect of which.

    1889 - There began a round of pleasure for Julia wherein she was the central figure.

  5. Into which.

    1585 - We came to an anker very nigh the castle, wherin when our patrone would followe vs [etc.].

Solution 2:

It's perhaps less common than it was before, but in general the construction of a preposition followed by a demonstrative or relative pronoun "this/these", "that/those", or "which/what" may be inverted by prefixing the preposition with "here-", "there-", or "where-", respectively.

in which == wherein
from that == therefrom
by this == hereby
after this == hereafter
for which, for what, why == wherefore
for that [reason etc.] == therefore
on that == thereon
to this == hereto

The inversion of a preposition in this manner is shared at least one other Germanic language, namely Swedish.