What causes an ovarian dermoid cyst?

Embryonic cells. Ectodermal embryonic cells enclosed into the ovary at early formation "get activated" later in life producing dermoid cysts, that can contain hair and teeth when surgically removed and opened.