This research investigates implementing and optimizing microgrid energy management systems (EMS) utilizing artificial intelligence (AI). Inspired by the need for efficient resource utilization and the limitations of traditional control methods, it addresses essential aspects of microgrid design, such as cost-effectiveness, system capacity, power generation mix, and customer satisfaction. The primary goals are to optimize energy management, control techniques, and AI applications in microgrids. The study critically examines the classification of energy management systems, various EMS applications, and their associated challenges. Additionally, it discusses different optimization techniques relevant to EMS, highlighting their applications, benefits, and challenges. The research emphasizes the importance of hybrid systems, demand-side management, and energy storage in addressing the intermittency of renewable energy sources. AI techniques, such as unsupervised learning (USL), supervised learning (SL), and semi-supervised learning (SSL), are extensively analyzed in relation to their specific applications. The study explores AI-based hierarchical controls at primary, secondary, and tertiary levels. Furthermore, AI methods like deep learning for load forecasting and reinforcement learning for optimal control are emphasized for their substantial contributions to enhancing microgrid reliability and efficiency. The research concludes that integrating distributed energy resources (DER) and using advanced optimization algorithms can lead to significant financial benefits and improved sustainability in microgrid operations. Over 200 research papers were referenced in this study.