I know for many this seems like a pretty easy task, and it is, but I wanted to run through it because of a common mistake people make. I have seen this dozens of times in my years of working on AR15s. Someone sends a rifle in and the action is locked up solid.  It won’t fire and nothing moves. Then I take the hammer and trigger out of the lower and see this:

What you are looking at is the top part of the pistol grip screw hole where it comes through the bottom of the inside of the receiver. The crumpled up spring is the safety detent spring.

What happens is someone buys an aftermarket pistol grip and removes the stock pistol grip to install it, and the safety detent spring falls out.  Sometimes the safety detent is also lost. They assume the spring must have fallen out of the screw hole so they put the screw in the hole and screw the new pistol grip on. Then they find the safety flops around and the action is locked up.

So here is the proper way to disassemble and reassemble a pistol grip:
With a 3/16″ T handle Allen wrench remove pistol grip screw and washer.

Keep receiver upside down on a table as shown as you remove the pistol grip.

Note above the safety detent spring and its proper placement in the safety detent hole.

Remove pistol grip. Note the gold safety detent in the hole. This is why it’s best to keep the receiver upside down so this does not fall out. 

This is the hole in the pistol grip where the safety detent spring goes.

And here are all the parts.

Sometimes the pistol grip washer is stuck up inside the pistol grip. If it is just poke it out through the top of the screw hole in the pistol grip. If the replacement grip does not come with its own screw, use the factory screw for installation of the new pistol grip. If it comes with its own screw be sure to use the screw that comes with it. Some grips have a different thickness inside and may require a longer or shorter screw than the stock screw. Also some pistol grip screws use a slotted screw instead of an Allen screw so a screwdriver is required for reinstallation. Reinstall the grip in the reverse order above. When you put the safety detent spring in its proper holes press the grip down and hold it on. This will line the screw up at the proper angle for reinstallation and you will not cross thread the screw.