A diode is used to block the electric current flow in one direction, i.e. in forward direction and to block in reverse direction. This principle of diode makes it work as a Rectifier.
For a circuit to allow the current flow in one direction but to stop in the other direction, the rectifier diode is the best choice. Thus the output will be DC removing the AC components. The circuits such as half wave and full wave rectifiers are made using diodes, which can be studied in Electronic Circuits tutorials.
A diode is also used as a Switch. It helps a faster ON and OFF for the output that should occur in a quick rate.