More than 50% of NHL players are Canadian, but 7/31 teams are based in Canada.
I assume it's just because the US provides a bigger market and therefore more revenue. But I'd be interested to hear more about the history.
It pretty much is that the US is a bigger market. While the NHL was formed in 1917 with 4 (quickly down to 3) Canadian based teams, it added its first American team, the Boston Bruins, in 1924. This was quickly followed by several more American teams. Granted two Canadian cities saw teams during this era, but one was a relocation from a different Canadian city (the Quebec Bulldogs moved to become the Hamilton Tigers, before that team was effectively moved to become the New York Americans), and the other was a second team in an existing city (the Montreal Maroons, who shared the city with the older Canadiens). After the Maroons folded in 1938, there would be no new Canadian team added until 1970 (the Vancouver Canucks).
An ownership group had applied for a team in Vancouver during the 1967 expansion, which saw the NHL double from 6 teams (2 Canadian, 4 American) to 12, but all 6 new teams were US-based, and that was no coincidence. The owners of the Canadian teams, the Toronto Maple Leafs and Montreal Canadiens, did not want to split broadcast rights in Canada with another team, as they were extremely valuable (NHL ownership making poor business decisions has a long history, one that continues to this day). A similar thing happened in 1979, when the rival World Hockey Association was to merge 4 of its last 6 teams with the NHL: 3 of those teams (Edmonton Oilers, Quebec Nordiques, Winnipeg Jets) were in Canada, and the initial vote by the NHL saw the merger rejected, with all 3 Canadian teams (and some American ones) voting against, again because they did not want to split revenues. On hearing this, hockey fans in Canada actually launched a boycott of Molson, a beer company and long-time sponsor of the NHL (the Molson family was also sometime owner of the Canadiens, and a member of them owns the team today). This proved super effective, and a re-vote on the merger saw Montreal and Vancouver change their vote (Toronto did not change their position, as their owner, Harold Ballard, was a notoriously cheap figure). Thus Canadian teams in the NHL doubled in 1979, going from 3 to 6.
This number increased again in 1980, as the Atlanta Flames packed up and left Georgia for Calgary, sold by an owner who was losing a lot of money in a major real estate downturn. There would be 7 Canadian teams for the next decade, increasing to a high of 8 in 1992 when the Ottawa Senators would "rejoin" (a previous Ottawa Senators had been an original team in 1917, but folded in 1934; the new team shared a name, but was a distinct franchise).
However the changing economic landscape of professional sports in the 1990s meant that this was not sustainable. Hockey salaries jumped incredibly in those years, seeing the average salary rise exponentially: in 1990 the average player made US$232,000 (itself nearly double what they were making in the mid-80s), while by 1994 that figure was $560,000 (in 2004 it had risen to $1.7 million). With Canadian teams earning revenue in Canadian dollars, and salaries (which peaked at about 73% of revenue in 2004) paid in US dollars, this was not easy to deal with, especially as the Canadian dollar saw a sharp drop in value in the 90s (it reached a low of about 63 cents US in 1998). This era also saw a massive stadium expansion, with sports teams across all the four major professional sports in North America (baseball, basketball, football, hockey) moving into new stadiums to take advantage of modern amenities like private suites and so on, increasing revenue potential. While many municipalities in the US helped finance (or even pay for) stadiums, this was not the case in Canada, and so teams started to struggle.
The first team to leave Canada was the Quebec Nordiques. In 1995 the owner, Marcel Aubut, had asked the Quebec government for help to replace the arena, but was refused, and instead sold the team. The new ownership moved them to Denver, Colorado to become the Colorado Avalanche. The next year a similar story happened with the Winnipeg Jets, who initially tried to move to Minnesota, but instead ended up in Phoenix, Arizona as the Coyotes. Edmonton also faced serious problems, and in 2000 they actually had a verbal contract to sell the team to a Houston, Texas-based owner, who planned to move them there. To stop a third Canadian team leaving, the NHL actually amended their by-laws and allowed an Edmonton-based consortium of 29 businessmen to group together and buy the team, keeping them there. The Ottawa Senators went bankrupt in 2003, and actually had to have a payday covered by the league in order to keep the team going, while the Vancouver Canucks and Calgary Flames also faced serious financial issues (the Montreal Canadiens fared a little better but still felt pressure, while the Toronto Maple Leafs have been an exception to the rule, and remain the most profitable team in the league).
As an addendum, I'll note that in 2011 a second Atlanta-based team, the Thrashers, were effectively forced out of the city, and sold to a Winnipeg-based ownership group. They brought the team to Winnipeg, and named them the Jets (again, a separate franchise from the original Jets, though the modern team does play up the history). As such there are 7 teams in the league now, and Quebec had put in a bid for an expansion team in 2016, but that was not accepted at the time. There is talk of an eighth team joining all the time, but seeing how that is grossly out of the bounds of history, I'm not going to touch on that.
This is a really short summary of things I realise, and doesn't touch too much on the initial efforts of the American expansion, but I hope it gives you a start. If you have follow up questions I'll be happy to answer, and can provide books on the subject as well if need be.