How to evaluate the research level of a paper before any publication? There are three differents cases when the research level of a paper must be evaluated before any publication:  


for author: to choose the most appropriate journal,
for referee: to recommend acceptance or rejection for a given journal,
for editor: to take the final decision.


If we compare this process to justice, a referee is like a lawyer, and an editor is like a judge.

Question: How an author, a referee and an editor can (respectively) evaluate the research level of a paper?    

We here ask about the purely research level of a paper, so we assume that the paper is original, correct and well-written. We also assume that the paper is  not too specialized if it is a general-audience journal, and is on-topic if it is a specialized journal (idem for any other specificity).  Finally, if specific, I am mainly interested in mathematical papers.  

An utilitarianism way could be to estimate how many papers should cite this paper in the next five years (self-citations excepted). Then the author can choose a journal having this number as Article Influence score (after renormalization), and the referee can check if it matches with the chosen journal. But then it would be necessary to know how to make such an estimate...

Of course, an author/referee/editor can evaluate the paper subjectively, but subjectivity varies with emotions, it can be manipulated and the process can become political. I wonder whether there is an objective way to proceed, or at least, if we can add a bit of rationality in this process. Consider the process of justice, it contains undeniably a part of subjectivity, but also rationality, called the law.
While I think your "justice" metaphor is wrong, the answer in all cases is experience. You need experience in the field as a reviewer. You need to know what has been done and what is important yet to do. As an editor you need either that field experience or experience with your reviewers - who is trustworthy and who is not. As an author in the early career you don't have any experience other than some within the field, but it will grow. 

For everyone here, the way you get experience is to make best effort attempts at whatever job you have and evaluate the response. As they say in engineering and computer science, "Good design comes from experience. Experience comes from bad design." 

If you are looking for an algorithm, then I would say it doesn't exist. It might be possible in theory to construct one with an AI looking at tens of thousands of interactions, but it might show bias, as many such things have been shown to do. 

But the system as a whole just depends on (nearly) everyone trying to do their best with what they have in front of them in world of imperfect information. 



In theory, theory is the same as practice. But not in practice. - Fnord Bjørnberger