Solomon is telling us that even the deeds we think are right are sinful, for if they were not sinful, they would not end in death. Death is the result of sin (Romans 6:23). So even the “good” things that we do without God are ultimately sinful because they arise from a corrupted nature.
Notice that Solomon is speaking of “a just man,” not an evil man or a corrupt man. The best citizens among us, those we raise to judgeships and listen to in church, have their own sins, and even in their doing of good, they cannot keep out the taint of sin.