Most halakhic discussions on the topic start with the Rambam in MT Melachim 1:5 (quoted above in comments)
We may not appoint a woman as king. When describing the monarchy, the
Torah employs the male form of the word king and not the female.
This principle also applies to all other positions of authority within
Israel. Only men should be appointed to fill them.
There has been heavy discussion on the proper understanding of this Rambam. There are a number of opinions, from rishonim to aharonim, who strongly limit its scope and thereby explain why women are appointed or elected as shul presidents (the classical case in much of recent rabbinic literature), members of Knesset and other positions of leadership.
R Howard Jachter provides a good summary here
The Rambam's major commentaries, the Kesef Mishnah and Radbaz, cite the Sifrei on the aforementioned verse, as the source for
the Rambam. However, the Sifrei merely states, מלך ולא מלכה, that a
woman may not be appointed as the nation's leader. The Rambam does
not have an explicit source for the extension of the Sifrei's rule to
any position of leadership.
[...]
Although the Rambam rules that a woman may not be appointed to a
position of authority, Rav Moshe and Rav Chaim David Halevi (the
Sephardic Chief Rabbi of Tel Aviv, in an essay published in Techumin
01:811-321) note that many Rishonim appear to disagree with the
Rambam.
Tosafot in Baba Kama 51a (s.v. אשר) write that a woman is permitted to serve as a דיין (a rabbinic judge). It is clear that
Tosafot believe that a woman can be appointed to a position of
authority.
The Sefer Hachinuch (Mitzvah 794) cites the Sifrei that a woman may not be appointed as king, yet he does not write that a woman
may not be appointed to any position of authority. Indeed, in the
next mitzvah, the prohibition to appoint a convert as king, the Sefer
Hachinuch writes that this law does apply to any position of
authority. Rav Moshe Feinstein writes that this seems to clearly indicate that
the Sefer Hachinuch does not agree with the Rambam.
Rav Moshe adds that it appears from both Rashi (s.v. כל) and the Ran (s.v. גרסינן) commenting on Kiddushin 67b that they do not
accept the Rambam's ruling. Rashi and the Ran explain that the source
for the rule that a convert may not be appointed to any position of
authority is from an extra word in the Torah מקרב אחיך תשים עליך מלך
(Devarim 71:51). The Torah could have merely stated "שום תשים עליך
מלך מקרב אחיך." The fact that the Torah adds another "תשים" teaches
that the rule forbidding appointment of a convert as king applies to
any position of authority.
It can be readily inferred from this comment of Rashi and the Ran that
they disagree with the Rambam. Finally, the Ramban (Shevuot 03a s.v.
וכן) and the Rashba (Ibid s.v. ולא) seem to also disagree with the
Rambam.
Modern poskim have different approaches to the issue (first four are from R Jachter's article) addressing both shul presidents and members of the Knesset
R Moshe Feinstein writes that although many Rishonim disagree with the Rambam, the Rambam's view should be followed in practice. He explains that since it is a matter of dispute (over a Biblical prohibition) that has not been settled in the Shulchan Aruch, in ordinary circumstances the Rambam should be followed. Thus, Rav Moshe writes, a woman should not be appointed as a president of a synagogue. However, in a case of great need, Rav Moshe felt it appropriate to rely on the Rishonim who disagree with the Rambam. For example, Rav Moshe permitted a poor widow to be appointed as a Kashrut supervisor, despite the fact that it is a position of authority
R Chaim David Halevi writes that the Rambam would explain these historical phenomena by stating that women cannot be imposed as leaders over the people. However, if the people accept her leadership, then the prohibition seems not to apply, Rav Halevi notes that this seems to follow what the aforementioned Rambam and Rashba said about Devora - she could serve as a ruler because the nation accepted her rulings. According to Rav Halevi a woman is permitted to be elected to a position of authority.
R Ben-Zion Meir Uziel (former Sephardic Chief Rabbi of Israel) adopts the same position (Teshuvot Mishpetei Uziel Choshen Mishpat 6)
R Yehuda Amital adopted this ruling in practice. In 1988 he allowed a woman to be on the parliamentary list of his political party Meimad. He explained that this ruling of the Rambam did not apply to a democratically elected position. According to this approach, it would seem that halacha would sanction a woman serving as a president of a synagogue, if she were to be democratically elected to that position.
R Aharon Lichtenstein noted that it is clear the dati-leumi/Modern Orthodox community and its rabbinic elite have clearly come down in favor of a more narrow reading of the Rambam’s restriction. He pointed to the fact that for the past two decades religious women have run for Knesset as candidates of dati-leumi religious parties across the board and some have served as members of parliament. In addition, a few have served as ministers in coalition governments with the approval (despite an occasional rumble here and there) of the rabbinic leadership of those parties. These have included scholars such as R. Avraham Shapira, R. Mordechai Eliyahu, Rav Yaakov Ariel and others. (from here)
R Gedalia Dov Schwartz (Av Beit Din of the Rabbinical Council of America) believes that the issues raised by the Rambam are not applicable to the position of synagogue president, and that, consequently, there is no halakhic prohibition (from here)
since 2013 the United Synagogue in the UK have elected women as presidents of synagogue communities, following a ruling of
the London Beit Din in 2012 that this was not in breach of halacha (from here which also brings a number of contrary opinions)
See also this very important article from Aryeh and Dov Frimer.