The ethico-mathematical analogy is ancient, but it did gain some recent prominence among analytic philosophers. Clarke-Doane's Moral Epistemology: The Mathematics Analogy, Franklin's On the Parallel between Mathematics and Morals, Lear's Ethics, Mathematics and Relativism all focus on the analogy. And all of them name book VII of Plato's Republic as its point of origin, where Plato outlines the work that the analogy is supposed to do:
"In mathematics, according to him, we come to perceive that which is universal, immutable and abstract: this is supposed to be relevantly similar to perception of the Good." [Lear] "Insight into the necessities of mathematics is apt for training the mind to love the necessities of ethics, and hence motivates the ruler to make this world conform to those necessities, to the degree that that is possible. The necessities of mathematics also make good models of absolute objectivity, for those seeking examples of truths independent of the arbitrary and subjective judgments of individuals and tribes." [Franklin]
It is the "self-evidence" of mathematical truths, despite the apparent lack of empirical input, and their peculiar "objective certainty", beyond that of any empirical surmise, that attracted many subsequent ethical rationalists to the analogy. If mathematics can credibly discover eternal truths, it went, so can ethics. This traditional use is rather problematic today.
Kant may still have been impressed by the mystiques of mathematical certainty and the moral law ("Two things fill the mind with ever new and increasing admiration and awe, the more often and steadily we reflect upon them: the starry heavens above me and the moral law within me"), and reserved the same mode of justification for both, his synthetic a priori. But already Hume had doubts about both, which Kant chose to overlook, and in mathematics at least the mystique went by the way of logicist "laws of thought" that Frege and Russell never quite found. After the wrangling over Cantorian infinities and the axiom of choice, intuitionism, Gödel's incompleteness, Cohen's set-theoretic pluralism, Quine (mathematics as holistic completion of empirical theories), late Wittegenstein (mathematics as "grammar"), etc., it is hard to see how the analogy can do the justificatory work that rationalists expected of it. Moreover, Dostoevsky, Nietzsche, existentialists, and the two world wars, provided quite independent reasons to cast aside the ethical rationalism itself.
Still, it is perhaps of independent interest to explore to what extent the analogy holds, irrespective of the use rationalists and moral realists put it to. One obvious problem is that while mathematics, at least prima facie, is a corpus of truths, this is not exactly the case in ethics. Per Humean view, "murder is wrong" is the imperative "do not murder" rephrased, and imperatives are not eligible for having truth values. This of course is a version of Hume's is-ought guillotine, "never the twain shall meet". Even if we get over non-declaratives having truth values somehow the next problem is the cultural and emotional neutrality of mathematics vs the opposite in ethics. Clarke-Doane creatively uses this wedge to argue that moral realism is more credible than platonism:
"One obvious difference between mathematical disagreement and moral disagreement is that the latter tends to track with personal and religious investment in a way that the former does not. But this disanalogy only bolsters the suggestion that mathematical propositions have no better claim to being self-evident than moral propositions. Mathematical disagreement typically occurs among the intellectually virtuous and seems to be largely independent of personal and religious investment. Such disagreement raises doubts about the supposed self-evidence of the relevant propositions far more effectively than paradigmatic moral disagreement."
But this argument seems odd to me. It can just as easily be turned around to argue that the apparent scarcity of personal and cultural biases in mathematical controversies makes it more credible that their subject matter has at least some claim to objectivity. If cultural dependence of "linguistic intuitions" is taken to go against the objectivity of their substrate why should it be different for ethical ones? The same is confirmed by what even Clarke-Doane himself points out in another context:
"Note that the puzzle in the mathematical case is not just that the relevant properties fail to participate in causal relata. The objects of which they are predicated fail to so participate as well. By contrast, moral truths are about objects that do participate in causal relata. For example, Osama Bin Laden, the Holocaust, and the Lincoln’s freeing of the slaves, all so participate."
But the self-evidence and objectivity of mathematics are arguably due to the abstract, non-empirical nature of its objects, which allows us fuller control over them. We do not see the definitional build-up in ethics on the same scale exactly because of its concreteness, nor do we see rigid logical arguments. One needs only to read the "proofs" in Spinoza's Ethics or Rawls' Theory of Justice to see how loose they are, and these are the authors who explicitly adopted Euclid as the standard! "We should strive for a kind of moral geometry with all the rigor which this name connotes", Rawls tells us. But of necessity rooted in the subject matter, ethical arguments are only heuristic, and weighted heavily by definitional vagueness and said or unsaid ceteris paribus clauses.
Perhaps there is way to salvage some aspects the analogy in a creative way, by giving up traditional realism on both sides. Mathematics survived, and remained credible, through all the controversies, despite the lack of "apodictic certainty" and necessity that Plato and Kant sought. Perhaps the analogy tells us that we should settle for something more human in ethics as well. Lear argues for "sophisticated cognitivism" on both sides along the late Wittgensteinian lines:
"Reality, truth, objectivity only make sense within the context of a form of life. If we wish to ground the objectivity of mathematics in something stronger, the sophisticated cognitivist argues, that could only be because we have not yet been cured of the desire to step outside our form of life and view it 'from sideways on', that is, from an external standpoint. If we sincerely abandon that desire, if the fever breaks, then we will no longer feel threatened by a collapse into natural history...
This does not mean that we can convince anyone outside our moral outlook to adopt it: for we've already admitted that outside our moral outlook there is nothing to which we can appeal to commend it. We can only make various appeals to get him to see a situation as we do; if he is not so disposed there is nothing more that can be done... However, this doesn't threaten the objectivity of ethics, it only reveals him to be insensitive. The objectivity of mathematics does not totter every time a child cannot be taught to add."