Numerous texts in the Old Testament (Hebrew Scriptures) show God as forgiving. Prayers for forgiveness are common, especially in the Psalms. God is asked to forgive because of the great covenant made with the people.
Often no motive is mentioned for asking forgiveness, but it is considered good to ask forgiveness since God is so forgiving. God will also forgive because of the goodness of some members of the group as we see in the example of Abraham who asked God to forgive Sodom and Gomorrah (Gen 18:26ff) if 50 or even 10 good men could be found.
Conditions for forgiveness in Hosea 14:3 are confession of sin, conversion and prayer for forgiveness. God can't forgive because some of the conditions are lacking.
Forgiveness figures prominently in the Gospels from beginning to end. John the Baptist preaches repentance for the remission of sin and Jesus forgives his executioners while he is on the cross and his unfaithful disciples after his resurrection.
During his public ministry, when Jesus was challenged for forgiving sin, he asked if it was more difficult for him to forgive sin than it was to heal. And since he was healing with God's power in him, so too he could forgive sin with that same power (Matthew 9:2, Mark 2:5, Luke 5:20).
The difference with forgiveness in the New Testament is that it comes through Christ in his personal forgiveness but also because of his redeeming death (Matthew 26:28). His death, which was redemptive, is in contrast with the animal sacrifices offered before to obtain forgiveness.
Does that mean that God doesn't forgive all sins? There is one exception and that is the sin against the Holy Spirit (Matthew 12:32; Mark 3:28; Luke 12:10). The exact identification of this sin isn't clear but it is likely a total and willful rejection of Christ, of God's love and forgiveness.
Jesus passes on his power of forgiving sins to the Church. "He breathed on them and said 'Receive the Holy Spirit, whose sins you shall forgive, they are forgiven them; whose sins you shall retain, they are retained'"(John 20:22-23). In Matthew 16:18-19, Jesus says to Peter: "You are Peter and upon this rock I will build my Church. I will give you the keys of the kingdom of heaven; whatever you bind on earth shall be bound in heaven; whatever you loose on earth shall be loosed in heaven."
The terms, binding and loosing, are not common in the Old Testament. Where they are used in Judaism, they indicate rabbinical decisions to impose or to remove obligations. Therefore, they convey authority. The Catholic Church has taken these words to mean that the authority to bind and loose given to Peter and the Apostles is passed on to their successors to reconcile sinners with the Church and with God.
In Matthew 18:15-17, the Church as a whole is called upon to exercise the power of correction within the community and exclusion when necessary. This seems harsh compared to the exercise of love and forgiveness by Jesus in his ministry. But even Jesus was powerless against those who refused to accept him.
Forgiveness is a free gift of God and is not due to any merit on the part of humans. However, in Scripture, Jesus forgives sin because of the faith of the petitioner and so faith is a good disposition to have. Confession of sin is also required for forgiveness, as well as conversion and the prayers of the Church (James 5:15ff).
Therefore, it is not God who refuses forgiveness but we ourselves who refuse. God offers us love and forgiveness but does not force us to accept. It is ultimately we who make the decision to accept or reject God. Jesus says: "I stand at the door knocking. If one of you open the door and let me in, I will come in and have supper with you" (Revelation 3:20).