Claudine Gay said she resigned as Harvard president to “deny demagogues the opportunity” to use her in their campaign to undermine the university’s mission.