Former king Juan Carlos to leave Spain amid investigation