Shut off power to the switch's circuit at the home's service panel (breaker box). Remove the two (or more) screws securing the switch coverplate. Remove the coverplate.
Confirm that the power to the switch is off by touching the probes of a circuit tester to the ground screw and to each screw terminal of the switch. You may have to remove the switch mounting screws and carefully pull the switch from the box to complete the test. Be careful not to touch any wires.
Remove the mounting screws (if you haven't already done so) and pull the switch from the box, clearly exposing each circuit wire. Compare the old switch with the new one to identify each corresponding screw terminal or wire lead. Also make sure the new switch carries the same voltage and amperage (amp) ratings as the old switch.
There are three basic types of standard light switches. A single-pole switch has two screw terminals plus a ground terminal. A three-way switch features three terminals plus a ground. Commonly used in stairwells and large rooms, three-way switches control the same fixture(s) from both switches. A four-way switch includes four terminals plus a ground. It's always installed between a pair of three-way switches, providing control of the same fixture(s) from three locations.
Disconnect each wire from the old switch and attach it to the corresponding terminal or lead on the new switch. If the wire ends appear blackened or otherwise damaged, cut back the damaged portion with wire strippers/cutters, then strip off 3/4 inch of the insulation before attaching the wire to the new switch.
Tuck the wires back into the electrical box, then secure the new switch in place with the provided screws. Reinstall the coverplate. Restore power to the circuit and test the switch.