In angry letter, US president tells Speaker Nancy Pelosi that 'history will judge you harshly' for using impeachment as 'illegal, partisan attempted coup'