Put down old newspaper or a tarp on the floor beneath the hole in the wall to protect the floor.
Cut away any bits of drywall that protrude out of the hole with a utility knife.
Scuff the painted area around the hole gently with fine-grit sandpaper.
Place a piece of nylon mesh tape over the hole, covering the entire hole. If you have small hole made, for example, by a screwdriver, this step is not necessary.
Smear spackle over the hole and tape using a putty knife. Smooth the spackle with the putty knife and allow it to dry according to manufacturer's directions. Sand lightly and apply another coat if needed.
Sand any raised edges with fine-grit sandpaper, then prime and paint the drywall.
Mark straight lines around the hole using a carpenter's level. Cut out the square using a drywall saw. Gently scuff the area around the hole with fine-grit sandpaper.
Take the measurements of the square opening with a tape measure, add 2 inches to each side, and trace with a pencil. Cut a scrap piece of drywall to these measurements with a drywall saw.
Place the square drywall patch face down, and trace out the measurement of the square hole using a speed square and pencil.
Score the lines on the drywall patch with a utility knife. Bend and crack the excess drywall. Peel the excess drywall rock from the paper using your hands. Repeat until all excess drywall is removed from the paper. You will have a square piece of intact drywall in the center and paper around each edge of the patch.
Insert the patch into the hole and verify it fits snugly. Adjust if necessary.
Smear a generous layer of joint compound around each side of the hole with a putty knife.
Insert and press the patch into the hole, smooth the brim (excess paper) down with a putty knife. Spread the joint compound, as it squeezes out from behind the brim, over the entire surface with a putty knife to patch the hole.
Place joint compound over the entire surface of the patch using a trowel, and allow it to dry according to the manufacturer's directions.
Sand raised edges with fine-grit sandpaper, and apply another coat of joint compound with a trowel. Make sure to feather out the edges. Repeat if necessary.
Sand the patch smooth with fine-grit sandpaper when it's completely dry, then prime and paint.