Why was Imam Ali (عليه السلام) named Amir al-Momineen (عليه السلام)

الْحُسَيْنُ بْنُ مُحَمَّدٍ عَنْ مُعَلَّى بْنِ مُحَمَّدٍ عَنِ الْوَشَّاءِ عَنْ أَحْمَدَ بْنِ عُمَرَ قَالَ سَأَلْتُ أَبَا الْحَسَنِ (عَلَيْهِ السَّلام) لِمَ سُمِّيَ أَمِيرَ الْمُؤْمِنِينَ (عَلَيْهِ السَّلام) قَالَ لانَّهُ يَمِيرُهُمْ الْعِلْمَ أَ مَا سَمِعْتَ فِي كِتَابِ الله وَنَمِيرُ أَهْلَنا.

وَفِي رِوَايَةٍ أُخْرَى قَالَ لانَّ مِيرَةَ الْمُؤْمِنِينَ مِنْ عِنْدِهِ يَمِيرُهُمُ الْعِلْمَ

Narrated that Abu al-Hasan Imam Musa al-Kazim (عليه السلام) was asked,

"Why was Imam Ali (عليه السلام) named Amir al-Momineen (عليه السلام)?

Imam Kazim (عليه السلام) said, "Because He provided (Mayr) knowledge (ilm). Have you not heard in the book of Allah, "And we will get provision/food (Mayr) for our family." (12:65)

And in another narration it is said, "The reason being that the provisions of the believers is from Imam Ali (عليه السلام), He provided them knowledge"

[Source: al-Kafi, Vol. 1, Pg. 412]

Note: In the above hadith, Imam Kazim (عليه السلام) has derived the meaning from the root word "مير - Mayr" which means "to provide"