This study employs density functional theory (DFT) to investigate the electronic and optical properties of alkaline-earth magnesium oxide nanocluster series, namely (MgO)6n (n = 1 to 9). As the number of (MgO)6 nanocluster unit increases in the (MgO)6n series, the electronic and optical behavior attributes a striking zigzag pattern. The analysis of energy gain in these clusters reveal a notably stable ‘magic’ nanocluster, namely, (MgO)42. Additionally, our findings uncover UV-B active optical transitions in the (MgO)42 magic nanocluster, suggesting its promising potential for possible applications in optoelectronics. Further, the analysis of infrared spectra of the (MgO)42 magic nanocluster, combined with electronic properties by cluster simulation, provides novel insights into its prospective synthesis. The promising properties of ultra-violet B active (MgO)42 nanocluster may further be explored for its low-dimensional customized assembled materials. Overall, the present study advances the fundamental understanding of sub-nanoscale MgO clusters, facilitating tailored design and versatile application across various technological domains.