To unlock legend mode you need to defeat the Moon Lord and then find the sky castle in the space layer. Here you will find a Golden Spear. Interacting with the Gold Spear will cause the Castle King to be summoned.
The Castle King will drop the Wand Of Curses and using this will start Legend mode which cause the spread of either the Oblivion or the Profanity as well as the Mountain Biome. This will add new monsters such as the Man-Goat and the Angry Witch.
The Angry Witch