Peter appears concerned that Jesus would not be esteemed a good Jew if He did not pay the tax. Not wanting to bring dishonor and danger on Him, he acknowledges Jesus' liability to pay the taxes as if He were a mere son of Israel. His reply implies that Jesus had paid the tax and would continue to do as every devout Jew should.
When Peter enters the house, Jesus immediately asks him about taxation: "From whom do the kings of the earth take customs or taxes, from their sons or from strangers?" This demonstration of Christ's knowing what Peter had discussed elsewhere proves to the disciple that His divine omniscience is not limited by distance.
Peter answers the question with the only possible answer, "From strangers," and Jesus replies, "Then the sons are free." He refers to Peter and Himself as both sons of the Father, the Sovereign of the Temple, and therefore, free from the tax. However, rather than cause offense, Jesus arranges for the money to be found in a most miraculous way.
Technically, Peter errs about the legality of taxing the Son of God, but Jesus uses the principle of not needlessly offending a brother (Luke 17:1-2) to positively express His divinity and spiritual power: He performs a miracle. Christ is so considerate that He would rather pay any amount, however unjust or objectionable, than endanger God's work by unnecessarily provoking negative comments that would hurt its credibility, saying, "lest we offend them" (Matthew 17:27). His example should inspire us for when we feel slighted or taken advantage of (Romans 14:21-22).