Collect the following: hammer, nails, gloves, tackless strips, utility knife or carpet knife, stapler and pliers.
Start at an edge and pull up old carpet underlay and discard it.
Use pliers to pull up all the staples that held the underlay to the floor. (Any staples left behind will create bumps in the new underlay and carpet.)
Remove glued underlay. This will require pulling up by hand as much old underlay as you can, and then applying a solvent (such as a citrus stripper) to soften the glue and scraping the remaining underlay off the floor.
Fill any holes in the subfloor surface and fasten any loose floor boards or panels to eliminate creaking floors.
Install tackless strips 1/2" from the wall, around the perimeter of your room (but not in front of doorways). Ensure the tacks point towards the wall and the strips meet at all corners.
Cut the underlay in strips that will run the length of the room, long enough to cover the tackless strips.
Install the underlay strips from one end to another. Put staples every 6-8 inches running from the inside of the tackless strip at one end of the room to the other.
Lay the underlay strips parallel to each other with their edges butting against each other (but not overlapping).
Trim away the excess underlay at the inside edge of the tackless strips all around the room.
Cover the seams with carpet or duct tape.