In 1983, Rod Temperton wrote the song "Starlight" for Michael Jackson forthcoming album. Producer Quincy Jones determined that the song would be a great title track but "Starlight" didn't cut it as an album title. From Wikipedia:
Instead, they wanted something "mysterious to match Michael's evolving persona." Temperton considered several possible titles, including "Midnight Man", which Jones felt was "going in the right direction". Finally, he conceived "Thriller", but worried that it was "a crap word to sing … It sounded terrible! However, we got Michael to spit it into the microphone a few times and it worked."
With the title settled, Temperton wrote lyrics within "a couple of hours". He envisioned a spoken-word sequence for the end of the song, but did not know what form it should take. It was decided to have a famous voice from the horror genre perform it, and Jones' then-wife, Peggy Lipton, suggested her friend Vincent Price. Temperton composed the words for Price's part in a taxi on the way to the studio on the day of recording.