The primary function of a p-n junction diode is to:
A p-n junction diode allows current in forward bias (low resistance) and blocks it in reverse bias (high resistance), making it ideal for rectification of AC to DC.
Ref: NCERT Physics Textbook for Class XI and XII, Chapter: Current Electricity, Topic: Resistivity, temperature dependence and circuit analysis.