A question sure to start an arguement. 17 HMR has more velocity than 22Mag and tends to be made with better bullets than most .22mag ammo. It has a flat trajectory out a long way and at distances over 100 yards it is far easier to shoot accurately in my opinion. .22 mag has more punch at shorter ranges with its heavier slug. The .22 is less affected by wind, but both are moved around by the wind. The .22 mag and the 17HMR are really hard on game like squirels at short ranges. Neither are made for large game, contrary to some folk's beliefs.
22LR and 17M2 are about the same comparison, but for shorter ranges. Many people including me use a .22 for under 75 yards. The Mach 2 takes it out to 100. The LR has more punch in the range it was made for, etc.
I have guns in all four chamberings, and all have uses. There is no one size that fits all. I do shoot far more .22 long rifle than all other bullets put together.