The first half of Galatians 2 addresses the fact that adding anything to salvation through faith in Christ voided God’s work of grace. Paul now opposes Peter because he’d stopped fellowshipping with the Gentiles who were Christians by grace through faith in Christ alone. Peter knew the truth that Jesus alone justifies, but his racism was rooted in fear of what other Jews would say, so he withdrew.
In essence his actions were testifying that Christ’s blood all by itself was insufficient to justify, which contradicted salvation through Christ alone. Peter’s hypocrisy and dividing racism was contagious, but Paul points out Peter’s error and then expounds on the implications of that error.
Now this wasn’t a “knock-down drag-out” kind of opposing; instead Paul reminded Peter that imposing the burden of keeping the Law on the Gentiles would only lead to failure and would insinuate that Christ’s shed blood was ineffective. Rather than threating him, he exhorted Peter to remember that his own justification was only through Jesus. No human effort can satisfy the penalty of our sin.
Because of and through Christ’s death we must die to trying to earn our salvation through performance and cling by faith to Christ’s matchless sacrifice. In other words if there was some way, any way that effort or religious performance could bring God’s righteousness then Jesus died needlessly. But in John 14:6 Jesus said “I am the Way, the Truth and the Life and no one comes to God except through Me.” God’s Way may be the road less travelled, but it is still the only One that leads to salvation.