This passage focuses in on the subject of unity in the Church, only barely mentioned earlier at the end of ch. 3. The first five verses look at the issue of dealing with sin among believers: it must be handled with gentleness and intent of reconciliation. And those who deal with sinners and confessions must be extra careful that they don’t fall into sin as well! And through all this, a tricky balance must be recognized between the call of mutual care (v2) and personal responsibility (v5).
Paul seems to change the subject in v6, but it can also be understood as a flip-side view of the first five: those who are taught (or helped through their sin) must give back to those who taught (or helped) them, otherwise they’re just mocking their teacher. For, fulfilling the law of Christ (see 5:14) requires to love others, not just receive.
So, as verses 8-9 go on to say, we must put into practice what we’ve learned. We reap what we sow, so we must keep the fruits of the Spirit and of the flesh (5:19-25) in mind as we consider how we live out our lives in the freedom of the gospel.
First and foremost through all of this, though, is the virtue of love – doing good to everybody as v10 puts it. Yet we show this love especially to fellow believers, for the sake of the unity of the Body.