Outtakes, demos, and notebook entries illuminate the genesis of one of rock’s most legendary characters — and how badly Bowie wanted it to work