Here's why:
* Episode 37 ("The Ancient Pokémon of the Sea") ends with Ash and his friends receiving invitations to a Pokémon tournament.
* The movie features this tournament, which serves as a setup for the main conflict with Mewtwo.
* Episode 38 ("The Mystery at the Lighthouse") starts immediately after the movie's events, with Ash and his friends returning from the tournament.
Therefore, the movie seamlessly fits into the storyline of the anime, serving as a special extended episode.