Rage Fist inflicts damage. Its power increases by 50 each time the user was hit during a battle (including times the user hit itself in confusion), up to a maximum of 300 (after 5 hits), with each strike from a multi-strike move counting as one hit. Switching out or fainting does not reset the hit counter.
No, leveling up should not affect the counter. Just use the move 20 times. Since it is a 10 PP move, you will need to use an Ether to refuel the PP.
Side note: My Primeape gained 3 levels as a result of using Rage Fist consecutively 20 times by just OHKOing, 2HKOing, or even 3HKOing various wild mons in the Asado Desert.