Here is a pic of the rifle dis-assembled. The barrel nut goes inside the quad rail, and squeezes the quadrail onto the upper. It also pulls the barrel tight against a metal bushing in the upper. The bigger part, above the threads is the part that stops the barrel from moving forward. The nut, keeps the barrel from moving backward, and holds the quad rail tight. There are "ears" on the barrel keeper that keep it from rotating. Those ears go into polymer channels in the upper. That is why you DO NOT hold onto the reciever to tighten or loosen the barrel nut. Only hold onto the barrel. There is a replacement barrel nut. It has inside threads for the 15-22 barrel and outside threads that are identical to an AR upper. Those are used for the barrel nut (not used on the 15-22) or for threaded AR forearms.
Hope these pics and info help. I have more.