What is the triangle-shaped headband these characters wear? I don't know what to call them, but I've seen these triangle-shaped things sometimes in anime:

 

What does the triangle-shaped headband mean and what is it called?
This triangle-shaped headband is called a tenkan (天冠, lit. "heaven crown"). In some parts of Japan, it may also be called a zukin (頭巾, lit. "hood" and also used as a generic term), a hitai-eboshi (額烏帽子, lit. "forehead headpiece"), or a kami-kakushi (髪隠し, lit. "hair-hider")2.

Traditionally, the tenkan was one component of a traditional burial garment (shini-shouzoku / 死に装束). The garment also typically included a white kimono, these glove-things (tekkou / 手甲), and a particular style of boots called kyahan (脚絆) that I'm having trouble finding a good picture of. 

There are a number of explanations of the purpose of the tenkan, including:


It must be worn to avoid offending Enma (a judge of the dead in Japanese Buddhist mythology; he's actually a derivative of the Hindu deity Yama)
It allows the dead to escape from hell
It functions as a signal that one was of high standing in life.


In anime today, I get the feeling that the tenkan basically serves as a signal to viewers that whoever is wearing it has something to do with death (or, more generally, with non-humanness, I guess).

Notes


This answer is mostly a translation of the following article: What's the triangular piece of cloth that ghosts wear on their heads? (Japanese)
This seems like it may be a pun on 神隠し, or "spiriting away" (as in the Ghibli film 千と千尋の神隠し, or "Spirited Away"). See also this question at Japanese.SE.