Couple of things:
1) Inter Miami is currently playing in the Leagues Cup which is a mid-season tournament between the MLS teams and Liga MX (Mexico) teams. They will resume their MLS schedule next week and still sit bottom of the league (though that is likely to change now that Messi is playing).
2) Inter Miami didn't just add a good player. They added the best player in the world and potentially the best player ever, and a guy that, though is on the decline, is still a dominant force at any level. He was the best player at the World Cup a mere 8 months ago and led a team that was not as talented as teams like France, Brazil, England, etc. to the title. Besides all of his physical skills, Messi is arguably one of the smartest players of all time as well (in terms of soccer/football IQ). He not only holds the records for career goals in the Spanish league but also assists. That means he makes everyone around him better as getting 300+ assist in a career means seeing passes and making passes that no other player can see or make.
3) They didn't just add Messi but Sergio Busquets and Jordi Alba. Both of those players were starters for FC Barcelona last year who won the Spanish League by over 10 pts over Real Madrid, and Sergio Busquets is a World Cup winner with Spain, while Jordi Alba won the European Championships with Spain. While they are both on the decline, they are still very, very good players. Sergio Busquets is one of the best holding midfielders in his generation and Jordi Alba is an excellent outside back. Furthermore, they have years and years of playing experience alongside Messi specifically. That sort of knowledge of each other's game, the runs that each other will make, etc. cannot be overstated.
4) MLS, while a league on the rise and competitive, is just not a great league. If you add 3 world class players to any team in MLS they are going to get remarkably better very, very quickly. Inter Miami actually had a decently talented roster and upgraded their coach as well when they brought Messi in by hiring Tata Martino who has led teams to trophies in Argentina, Paraguay, Spain, and won MLS cup with Atlanta United. His overall impact on Inter Miami's turnaround is big as well.
So, all of these factors together are the reason that Inter Miami have made such a rapid turnaround.
*Edit to add that Tata Martino (who is Argentinian) has coached Messi with both FC Barcelona and Argentina. Messi likes Tata Martino and one way to guarantee to get solid play out of an International Superstar is to hire a coach that he likes/respects. I don't believe Messi would be playing as well for Inter if someone like Berhalter or Bruce Arena was the coach there as they would not have his immediate respect.