That's Paul's way of reminding the Christians to not put too much stock in their works for salvation --- even works required by God in the Old Testament.
Yet Paul goes on in the later part of the chapter to say not to forget works altogether either. As you correctly point out that people who do those won't inherit the kingdom of God. And then he goes back to the circumcision-isn't-part-of-salvation argument in chapter 6.
So what does it all mean? I mean all of it together, not just a few verses here or there? I take it to mean:
1) Don't get caught up in works as far as salvation.
2) But don't think being saved by grace gives us license to live like we ain't saved. If we aren't believers enough to change our lives, then we need to question if we really are believes (and by extension aren't saved).
3) But Paul goes back to what I point out as point #1 -- actions still ain't enough to be saved.
Since Paul repeats that I'll repeat it too -- be careful not to put too much into works when it comes to salvation. Us Protestants also need to remember to live it like we mean it, but Catholics need to be weary of putting too much into works when it comes to salvation.
That we cannot be saved by circumcision and the Mosaic Law.
But don't think being saved by grace gives us license to live like we ain't saved. If we aren't believers enough to change our lives, then we need to question if we really are believes (and by extension aren't saved).
So we are not saved by faith alone: faith must be accompanied with changing our lives, i.e. good works.