Elon Musk is trying to end an agreement to buy Twitter Inc. for $44 billion and take it private, alleging that the company misrepresented user data and setting the stage for an arduous court brawl.