As promising solutions to various social and environmental issues, the generation and integration of renewable energy (RE) into microgrids (MGs) has recently increased due to the rapidly growing consumption of electric power. However, such integration can affect the stability and security of power systems due to its complexity and intermittency. Therefore, an optimal control approach is essential to ensure the efficiency, reliability, and quality of the delivered power. In addition, effective planning of policies for integrating MGs can help promote MG operations. However, outages may render these strategies inefficient and place the power system at risk. MGs are considered an ideal candidate for distributed power systems, given their capability to restore these systems rapidly after a physical or cyber-attack and create reliable protection systems. The energy management system (EMS) in an MG can operate controllable distributed energy resources and loads in real-time to generate a suitable short-term schedule for achieving some objectives. This paper presents a comprehensive review of MG elements, the different RE resources that comprise a hybrid system, and the various types of control, operating strategies, and goals in an EMS. A detailed explanation of the primary, secondary, and tertiary levels of MGs is also presented. This paper aims to contribute to the policies and regulations adopted by certain countries, their protection schemes, transactive markets, and load restoration in MGs.