The subject of a relative clause like this is usually the noun or noun phrase that immediately precedes it. Applying this rule, however, results in a sentence that is pragmatically unlikely, since it would mean "the necklace unlocks the box".
So we look for another noun that is more likely to fit the meaning, and find "the key". We pragmatically choose that as the probable subject of the relative clause, and the noun that is being modified.
This can be called a "misplaced modifier", since the phrase is separated from the noun it modifies, and sounds a bit awkward. But fixing it would require rephrasing, as there are two modifying clauses and they can both go right after the word "key". So you would use a pronoun:
This is the key that was in the necklace. It unlocks the box my birth certificate was in.