While facing grief, illness and a very public breakup, the comic reached for his diaries – and found a happy kid who spiralled into despair. Inspired by a Nobel laureate, he wrote a frank, funny book ...