Shared ground
These two verses hold together two claims: what the speaker observes “under the sun,” and what he concludes “in [his] heart.” Explicitly, he sees that wrongdoing can occupy the very “place” meant for justice and righteousness. The text assumes people expect public decision-making spaces to be fair, and it bluntly notes the mismatch.
Explicitly, the speaker also asserts that God will judge both the righteous and the wicked. That assertion is tied to the earlier theme that there is an appointed time for matters and deeds (3:1–15). The passage does not say the courts will fix themselves; it moves the question of final moral accounting to God.
Where interpretation differs (only where needed)
What “place of justice/righteousness” means. Many read it as law courts and administrative centers (formal judging spaces). Others take it more broadly as any setting where right decisions should be made (leadership, institutions, society’s public life).
What “there” refers to. Some understand “there” as pointing back to those public places: even if justice is corrupted here and now, God has a time “there” (in that realm of human affairs) to deal with every deed. Others hear “there” as shifting the scene to God’s arena: the timing and location of judgment belong to God, not to the corrupt courts.
What kind of judgment is in view. Some think the judgment can include events within this life (God’s providential reversals in history). Others think the speaker must be pointing beyond this life, because the injustice described is not reliably corrected in ordinary experience.
Why the disagreement exists
The passage is brief and uses flexible words (“place,” “there,” “time”) without specifying the mechanism or setting of judgment. It also juxtaposes an empirical claim (“I saw under the sun…”) with a theological conclusion (“I said in my heart…”). Readers differ on how tightly verse 17 is meant to answer verse 16 in observable history versus in a final accounting that may not be visible “under the sun.”
What this passage clearly contributes
It contributes a sober realism: systems designed for justice can be corrupted, and this is not surprising “under the sun.” It also contributes a counter-claim to despair: injustice is not treated as the last word, because God’s judgment includes both the righteous and the wicked and is connected to an appointed time for “every purpose and…every work” (Ecclesiastes 3:16–17). The text’s explicit emphasis is on the certainty of judgment and the certainty of timing, not on detailing how or when the judgment becomes visible.