This theme is sort of a recurring theme in Toby Fox's work. It originated in his Earthbound Halloween Hack as the final boss theme and since then has made appearances in his other musical works, like Homestuck.
And now, it's in Undertale, in its best version yet.
GO PLAY UNDERTALE.