Lichs are powerful undead that are undead wizards' remains.
Wizards wishing to attain Lichdom must make a demonic pact and choose an item to become a phylactery to feed souls to. If a lich fails to feed souls it will become a Demilich.
The first lich was allegedly Vecna, a wizard that, despite all his power, couldn't stop death. He managed to make a deal with the Demon prince Orcus that allowed him to become a lich. Vecna was eventually brought down by his lieutenant Kas the Destroyer, but his spirit survived, and he eventually became the god of dark secrets.
Strictly speaking, there are two types of Demilichs.
One kind is the lich that forgets or fails to feed enough souls to its phylactery and becomes a demilich.
The other kind is the lich that tries to become one on purpose like Acererak who insetted eye gems in his eye sockets that would drain the souls of those who touched them.