A longtime Twitter insider and a confidant of co-founder Jack Dorsey, Mr. Agrawal takes over as the social media company confronts various challenges.