Musk swooped into the race shortly after Trump’s inauguration. Republicans were pessimistic about being able to win the seat.