I can't tell you what the rationale of the government was. I'm sure it was a concern about housing affordability. Of course, homes that aren't used as primary residences, be they by non-Canadian or Canadian people able to afford second homes, take away the affordability for people who just work for a living in a given market and want to live in a home.
On June 5th, 2023. See this statement in context.