What is the purpose of a demand letter? In what specific circumstances will it be used?

What is the purpose of a demand letter? In what specific circumstances will it be used?