In Scripture, righteousness is often a legal term, not a moral one. It means that a judge would pronounce someone righteous. Naturally, the ideal was that the person would actually be righteous, but the focus is on what the judge said. The verdict did not necessarily depend on the moral realities. In accord with that, the primary question of both Judaism and Christianity was “what must a man do if God is to declare that he is in the right and so give judgment in his favour? The Jewish answer was that he must obey the Law of Moses. For Paul, a righteousness attained by the law was only a relative self-righteousness. The best that could be hoped for was the blamelessness of which he spoke in 3:6b, but which he nonetheless had found inadequate for gaining salvation. Thus, the law provides one approach to righteousness, but it is a flawed approach. The problem is not the law. Paul taught that the law is good (Rom 7). The problem is the sin which indwells each person (Rom 7:13–25). Clearly, no one has the kind of righteousness that will secure a verdict of innocent when God examines the life.
Melick, R. R. (1991). Philippians, Colossians, Philemon (Vol. 32, p. 133). Nashville: Broadman & Holman Publishers.