Former president’s ‘ego’ behind decision to stay in race against Trump in US election, ex-contender says in book extract