Some African tribal groups, like the Luo of Kenya or the Tigray of Ethiopia/Eritrea, place a lot of emphasis on intellectual ability and educational background. Being smart and coming from an educated background automatically makes a person suitable for leadership among those people, and their kin show them deference. That is why the Tigrays picked Meles, even though he was very short and sickly, to be their leader---he was very smart and did university studies in medicine. Their choice was excellent as Meles lead them to many decades of power in Ethiopia. Somalis, on the other hand, don't have a culture that places that much importannce on intellect or educational background. Being smart and educated is definitely a plus in Somali culture, but is secondary to other traits like clan background, or appealing to dominant Somali instincts such as unrealistic nationalist sentiments or religion.
Farmaajo does not appeal to religion, but he does (or did) a good job of appealing to nationalist sentiments. This includes promising a level of government that is unrealistic for Somalia, and he also does a lot to remind people about the time of the central government which adds to his appeal. This is why he was elected. Nobody choose Farmaajo for his educational credentials, which like you say are a bit mediocre. Nonetheless, by Somali standards, he's fairly well educated. Some Somali leaders can't read or write, while he has a masters degree from a decent regional school in the U.S. By my estimation, Gaas of Puntland is the best educated Somali leader and with the highest IQ, but he lacks charisma (which Farmaajo has), and Gaas does not appeal to any of the main instincts Somalis value (religion, nationalism). Because of this, Gaas is unlikely to ever become president.