There are two different levels going on in your question and they are often confused: Individual Forgiveness and Societal Justice.
First, is, what should an "individual" do? Individual responsibility toward their neighbor. This is the level of forgiveness.
Second, is, what should the greater community do? How do we administer a community where there is order and stability? This is the level of justice.
Take for example the case of Dr. Larry Nassar - the doctor for the US Women's Gymnastics Team. On an individual level, many of the women chose to forgive him. The choice is to release the upset. To free yourself from the burden of the upset. To not bear a grudge or seek revenge (Leviticus 19:18).
Rachael Denhollander both forgave Nassar and demanded justice.
But on the level of community - the prosecuting attorneys and the Justice System - Justice MUST be served. If a community does not serve justice then we would likely expose more innocent people to the harm of a molester. The societal bureaucracy (the Justice System) is what we rely upon to ensure proper justice is served.
If the system of justice breaks down - people will revert to revenge. This always ends badly and Jesus does not want us to go there. Again, see Leviticus 19:18.
In the Old Testament, you find a combination of the two. For instance:
Deuteronomy 16:18-20 deals with appointing judges within the community to hear disputes and make rulings:
Appoint judges and officials for each of your tribes in every town the Lord your God is giving you, and they shall judge the people fairly. Do not pervert justice or show partiality. Do not accept a bribe, for a bribe blinds the eyes of the wise and twists the words of the innocent. Follow justice and justice alone, so that you may live and possess the land the Lord your God is giving you.
Also see Deuteronomy 17:8-13. This is directed at the community.
Exodus 23:2-3 tells you, as an individual, how you are supposed to respond to matters of Justice:
“Do not follow the crowd in doing wrong. When you give testimony in a lawsuit, do not pervert justice by siding with the crowd, and do not show favoritism to a poor person in a lawsuit.
Also, notice you are not supposed to show favoritism to someone just because they are poor.
Now forgiveness. Forgiveness is an act for an individual that was wronged.
Forgiveness is necessary because it is the process that releases the upset caused by others. If you don't release the upset you will likely become bitter, angry, and vengeful. This will not serve proper justice.
Notice Leviticus 19:18. "Do not seek revenge or bear a grudge" - both of these carry the presupposition that someone wronged you. Why else would you "bear a grudge?"
Now go to the second half - "but you shall love your neighbor as yourself."
How do I move from wanting to "seek revenge" to "loving my neighbor?"
Jesus wants you to forgive so that you don't become bitter and vengeful.
But Jesus is also concerned about PROPER justice. If we do not have proper justice in a society thigs will literally go to Gehenna quickly.