The Apostle Paul said,
19. Now we know that whatever the law says, it says to those who are under the law, that every mouth may be stopped, and all the world may become guilty before God.
20. Therefore by the deeds of the law no flesh will be justified in His sight, for by the law is the knowledge of sin. Romans 3:19-20
Jesus said,
17. "Do not think that I came to destroy the Law or the Prophets. I did not come to destroy but to fulfill.
18. "For assuredly, I say to you, till heaven and earth pass away, one jot or one tittle will by no means pass from the law till all is fulfilled. Romans 3:19-20
When Jesus spoke to "the rich young ruler" and disappointed the young man with His answers (mainly with the suggestion that he should give up his wealth for charity's sake and follow Him) He stated,
23. Then Jesus said to His disciples, "Assuredly, I say to you that it is hard for a rich man to enter the kingdom of heaven.
24. "And again I say to you, it is easier for a camel to go through the eye of a needle than for a rich man to enter the kingdom of God.''
We understand this to mean that Jesus saw the man's heart and that He placed more value on his wealth than on his salvation.
Then we see this interchange with His disciples:
25. When His disciples heard it, they were exceedingly amazed, saying, "Who then can be saved?''
26. But Jesus looked at them and said to them, "With men this is impossible, but with God all things are possible.''
Is this passage teaching the necessity of poverty for salvation? Or was Jesus teaching that men can't be saved by anything they do, because salvation is the work of God alone?
There are exactly 0 (zero) contradictions between the teaching of our Lord and that of His apostle. Paul didn't teach that the law was abrogated, but rather that Jesus fulfilled the law (even as He said) and became the propitiation of our sin, and that working the works of the law to be counted as righteous now that the new covenant is established is sin,:
4. Now to him who works, the wages are not counted as grace but as debt. 5. But to him who does not work but believes on Him who justifies the ungodly, his faith is accounted for righteousness, 6. just as David also describes the blessedness of the man to whom God imputes righteousness apart from works: 7. "Blessed are those whose lawless deeds are forgiven, and whose sins are covered; 8. blessed is the man to whom the Lord shall not impute sin.'' Romans 4:4-8
To be clear here, Paul didn't teach that doing the works of the law was somehow wrong, but what he did teach was that doing them to be righteous or justified before God is sin. But did Jesus say anything like what Paul said in chapter 4 of Romans?
"So likewise you, when you have done all those things which you are commanded, say, `We are unprofitable servants. We have done what was our duty to do.' '' Luke 17:10
I'd say that Jesus made it pretty clear that keeping the commandments is a duty and not some way of earning merit or favor with God. Keep in mind that He said, "But go and learn what this means: `I desire mercy and not sacrifice.' For I did not come to call the righteous, but sinners, to repentance.'' Matthew 9:13 and, So He said to him, "Why do you call Me good? No one is good but One, that is, God. But if you want to enter into life, keep the commandments.'' Matthew 19:17
The point of all of these sayings of Jesus is that He came to fulfill the law, because no ordinary man could. Jesus knew the book of Deuteronomy well, quoting it often, and what does that book say with regard to keeping the law?
"But it shall come to pass, if you do not obey the voice of the Lord your God, to observe carefully all His commandments and His statutes which I command you today, that all these curses will come upon you and overtake you: Deuteronomy 28:15
This was no less true in Jesus' days as a man in the flesh, than it was in Moses' day, and the Apostle explained this for our understanding in his epistle to the Romans. There are no contradictions. Jesus fulfilled the law with His life and paid the price of our sin with His death. Consider that when we see Jesus speaking in the gospels, it is usually to Jews who were by covenant under the law. The law never applied to the world, but Paul goes to some length to explain that the gentiles are judged by the law because an understanding of the points of the law is built into human nature. (Conscience is universal, but conscience can be silenced by repeated patterns of sin.)
Paul also explained that God has confined all under sin so that His promises would be kept to those who believe Christ: 22. But the Scripture has confined all under sin, that the promise by faith in Jesus Christ might be given to those who believe. 23. But before faith came, we were kept under guard by the law, kept for the faith which would afterward be revealed. 24. Therefore the law was our tutor to bring us to Christ, that we might be justified by faith. 25. But after faith has come, we are no longer under a tutor. Galatians 3:22-25
The scripture isn't a collection of rules for us to follow to heaven, but is the testimony of God about Himself given through angelic beings, prophets inspired by His Spirit, and finally by His Son (and those chosen to be found in Him.) Its also a testimony about men, our fallen nature, and the only hope of our redemption through faith in Jesus Christ.