The following passage shows that the Pharisees thought illness was punishment as the result of sin. However, John 9 shows Jesus did not believe that. However, he used the Pharisee's belief to show he could forgive sin.
And when he saw their faith, he said, “Man, your sins are forgiven you.” 21 And the scribes and the Pharisees began to question, saying, “Who is this who speaks blasphemies? Who can forgive sins but God alone?” 22 When Jesus perceived their thoughts, he answered them, “Why do you question in your hearts? 23 Which is easier, to say, ‘Your sins are forgiven you,’ or to say, ‘Rise and walk’? 24 But that you may know that the Son of Man has authority on earth to forgive sins”—he said to the man who was paralyzed—“I say to you, rise, pick up your bed and go home.” 25 And immediately he rose up before them and picked up what he had been lying on and went home, glorifying God. 26 And amazement seized them all, and they glorified God and were filled with awe, saying, “We have seen extraordinary things today.”
(Luke 5:20–26, ESV)
From John 9:1 apparently Jesus' disciples believed this, but Jesus taught them otherwise. Someone being born blind was a particular problem when it came to punishment for sin. However, John included this miracle because:
Never since the world began has it been heard that anyone opened the eyes of a man born blind.
(John 9:32, ESV)
as well as:
As long as I am in the world, I am the light of the world.
(John 9:5, ESV)
Yes, the Pharisees contradicted Jesus by holding to there beliefs:
ἐν ἁμαρτίαις σὺ ἐγεννήθης
(in John 9:34, NA28)
"you became in sin"
While the blind man's statement supported Jesus':
The man answered, “Why, this is an amazing thing! You do not know where he comes from, and yet he opened my eyes. 31 We know that God does not listen to sinners, but if anyone is a worshiper of God and does his will, God listens to him. 32 Never since the world began has it been heard that anyone opened the eyes of a man born blind. 33 If this man were not from God, he could do nothing.”
(John 9:30–33, ESV)
Jesus' statement supported:
Jesus answered, “It was not that this man sinned, or his parents, but that the works of God might be displayed in him.
(John 9:3, ESV)
The Pharisees would not deny that the blind man's healing was from God, they contradicted Jesus' purpose in the miracle:
Give glory to God. We know that this man is a sinner.”
(John 9:24, ESV)
We know that God has spoken to Moses, but as for this man, we do not know where he comes from.”
(John 9:29, ESV)
John 9 concludes with is irony in Jesus' statement. Physical blindness isn't the result of sin, but spiritual blindness is.
Jesus said, “For judgment I came into this world, that those who do not see may see, and those who see may become blind.” 40 Some of the Pharisees near him heard these things, and said to him, “Are we also blind?” 41 Jesus said to them, “If you were blind, you would have no guilt; but now that you say, ‘We see,’ your guilt remains.
(John 9:39–41, ESV)
This was especially ironic because it was the spiritual leaders that were bind.
Jesus answered him, “Are you the teacher of Israel and yet you do not understand these things? 11 Truly, truly, I say to you, we speak of what we know, and bear witness to what we have seen, but you do not receive our testimony. 12 If I have told you earthly things and you do not believe, how can you believe if I tell you heavenly things?
(John 3:10–12, ESV)