Context is crucial here:
17 Think not that I am come to destroy the law, or the prophets: I am not come to destroy, but to fulfil.
18 For verily I say unto you, Till heaven and earth pass, one jot or one tittle shall in no wise pass from the law, till all be fulfilled.
19 Whosoever therefore shall break one of these least commandments, and shall teach men so, he shall be called the least in the kingdom of heaven: but whosoever shall do and teach them, the same shall be called great in the kingdom of heaven.
20 For I say unto you, That except your righteousness shall exceed the righteousness of the scribes and Pharisees, ye shall in no case enter into the kingdom of heaven." (Matthew 5:17-20)
The commandments are from the Law. One who breaks the least of those commandments and teaches others to do so will be called least. That's really all there is to it. It has no bearing on salvation, but there is a requirement to get into the kingdom of heaven: that your righteousness surpasses that of the Pharisees. To understand what this means, we must know what righteousness and the level of Pharisaical righteousness is.
1 John 3:7 Little children, let no man deceive you: he that doeth righteousness is righteous, even as he is righteous.
The righteousness that is by faith also practices. Indeed, Romans 3:21-22 points to this:
But now apart from the Law the righteousness of God has been manifested, being witnessed by the Law and the Prophets, even the righteousness of God through faith in Jesus Christ for all those who believe; for there is no distinction
So now we have to ask: what is the righteousness of the scribes and Pharisees? Was their righteousness really the righteousness witnessed by the Law that is practicing righteousness? Did they really practice the Law?
Matthew 23:1-3: Then Jesus spoke to the crowds and to His disciples, saying: “The scribes and the Pharisees have seated themselves in the chair of Moses; therefore all that they tell you, do and observe, but do not do according to their deeds; for they say things and do not do them.
The Pharisees read the Law, and told people to do it... only for them to do entirely different things. In essence, they were hypocritical and defiant. They would see the Law, and how God intended for them to do something, realize that it applied to them, and then instead, decide that they wanted to do something else. So the condition that our faith in Christ merits righteousness hinges on us doing what we believe God wants us to do. In essence, it's a matter of believing God, as Abraham did (Genesis 15:6 - the word 'in' is not in the Hebrew or the Greek). If we believe God, we will try to do what He says we should do. We will fail, but that's what grace is for. Someone who is least in the Kingdom will commit sin without being convicted of it because he or she does not know that it is sin - but that person is accounted righteous by faith because that faith makes that person avoid what he or she does know to be sin. The reason idolaters and fornicators don't get in (without first choosing to stop being idolators or fornicators by repentance through belief in Christ) is because they already know that such things are wrong, as that part of the law is written on their hearts:
For when Gentiles who do not have the Law do instinctively the things of the Law, these, not having the Law, are a law to themselves, in that they show the work of the Law written in their hearts, their conscience bearing witness and their thoughts alternately accusing or else defending them, on the day when, according to my gospel, God will judge the secrets of men through Christ Jesus. (Romans 2:14-16)
The idolator knows that idolatry is wrong instinctively, as every man knows that wood, stone, and metal can't actually 'tap into' the divine, and they know that the real Creator of the Universe must be an invisible God who exists outside of the Universe. That's why the idolator stands condemned before the LORD.