First a correction: In Mt. 17 Jesus does not say the Son is exempt from paying taxes to the Father. (This may be true, but he does not say so.) He says that only foreigners have to pay tolls and census taxes, but subjects do not. The temple tax was imposed by God on his people and Jesus taught that the temple tax should indeed be paid. This is the meaning of "render unto God what belongs to God." (Matthew 22:21) In that sense, Matthew's account of the temple tax seems to compare apples to oranges. The historic temple tax was imposed by Jewish authorities, even when the Romans were in charge. The census tax as described by Jesus is a different matter, imposed by a king on foreigners.
(One explanation of this apparently discrepancy is that the account is an anachronism based on the time when Matthew was written, when the Romans forced Jews to pay a temple tax for the upkeep of a non-Jewish temple see footnote here).
Regarding John's baptism, even Jesus would become ritually impure from time to time. This is not a sin in the moral sense, but it does require that the person bathe in water. (Lev. 15) This may be what he referred to in his conversation with John in Mt. 3:15. In this sense I would answer yes to the OP's question about John's baptism. Both immersion and paying the temple tax were religious duties that, at least during his lifetime, Jesus taught should be observed.
The miraculous provision of the temple tax is apparently due to the poverty of Jesus and the disciples, who carried no money and relied on charity for their daily needs. (Matthew 10:9-11)
9 Do not take gold or silver or copper for your belts; 10 (no sack for
the journey, or a second tunic, or sandals, or walking stick. The
laborer deserves his keep. 11 Whatever town or village you enter, look
for a worthy person in it, and stay there until you leave.
As Peter declared, Jesus taught that his disciples (probably himself as well) were supposed to pay the temple tax. Since they did not carry money and the tax-collectors were demanding payment, God provided the means for them to pay.
Conclusion: Yes, Jesus had a religious obligation to pay the temple tax, as well as to follow the rule to cleanse oneself after accidentally becoming ritually impure. Both of these duties applied at this time in history, whether or not one has sinned.