The Mansion Key is an item which allows you to enter the Mansion Doors inside the part of the Nightmare that can be accessed from the Gargoyle's room.
Talking to the grey Ratfolk in Topple Graveyard will trigger one of several dialogues. One of them will result in the player being given the Mansion Key. Once obtained, it will appear in the player's inventory.
The Mansion Key may also be dropped by the Nightmare-specific enemies that spawn in the Mansion.
If the Mansion Key is discarded or sold by the player, you can talk to the Pig to get it back. It will not be lost on death.
Enemies that may drop the key: Ants, (continue the list)