W.D. Gaster was the old King of New Home and is Sans’ and Papyrus’ father. He was appointed as a king from the citizens after the old king, Asgore’s father, was about to die of old age, because his son was too inexperienced and a bit young to the citizens' tastes at the time.
He, along with Undyne and Alphys, died because of a strange explosion in the old labs, though his ghost was never found, which confused some citizens. Some speculated that he used special magic to seperate the two's souls from their body to save them, but didn't have enough time to use the spell on himself.
Gaster was a nice person. He built the CORE to solve the Underground's energy problem. When he died, everyone grieved.