Things You Will Need
Light switch, Phillips screwdriver, Flat blade screwdriver, Wire Stripper, Circuit tester, Electrical or masking tape for marking wires if working on a three way switch
First of all, electricity can be dangerous if not given the respect it deserves. That said the first step is to turn off the power at the breaker box. Mark the breaker with a warning that you are working on the circuit so no one mistakenly turns the power back on. Test the circuit to make sure it is off.
Remove the switch cover plate using a small flat blade screwdriver to remove the two screws holding it in place. Next, remove the two Phillips head screws holding the switch itself in place. Gently pull the old switch out of the box and note the position of each wire. This is especially important if working on a switch that is part of a three-way circuit. A three-way circuit is simply a light that is controlled by more than one light switch. I suggest marking the wires with masking tape or colored electrical tape. For the three-way circuit to work properly, it is necessary for the wires to be installed in the same positions on the new switch that they were on the old switch. On a normal switch it is just important to note the wires so that when the switch says off, the light is off.
On some switches the wires are placed under brass screws and you simply loosen the screws and remove the wires. Others have the wires inserted into the switch. These can be a little tricky to get out. Usually there is a small hole above or to the side of where the wire is inserted. Insert a small nail or similar object into the hole to release the wire. Sometimes you can simply twist the wire and switch gently from side to side while pulling on the wire to remove it. If all else fails, you can cut the wire at the base of the switch. I would do that as a last resort however because there is not a lot of excess wire to work with. If you do cut it, you will have to strip the wires before installing them. Most switches have wire length gauge on the switch to show you how much insulation to remove from the wire.
Connect the wires to the new switch in the same positions as the old switch. Gently push the wires and new switch back into the box and attach it with the two Phillips screws. Next replace the cover plate using the two slotted screws. Turn the power back on at the breaker box and test the installation. This is sometimes referred to as the "smoke test". If you hear any noise such as a crackle or pop when the light is turned on, disconnect the power again and check the wiring to make sure there are no exposed wires that may be coming in contact with the box or other wires.
A light switch can wear out and need to be replaced. It is easy and straight forward project that only about 10 minutes. Switches are available at home centers, hardware stores, discount stores such as Wal-Mart and even grocery and drug stores.
Tips & Warnings
Most switches are standard but you may want to remove the switch and take it to the store to ensure you have the exact replacement switch. The individuals at the hardware stores and home centers can assist you in making the right selection.
Replace switches during the brightest part of the day to provide the best possible natural light while you are working.
Electricity is potentially dangerous. Always treat it with respect and make sure you turn the power off and mark the breaker with a notice that you are working on the circuit.
If you are uneasy doing electrical work, hire a professional electrician.