When he was a small child, Sherlock didn’t understand lying.
He couldn’t understand how people could just make up facts, facts they knew weren’t true, and it took him some time to wrap his mind around the idea. It took him much, much longer to understand that not all untruths are conscious lies - that most of the time, people say things that are wrong because they don’t know better, or because they just don’t care that they are wrong.
After Sherlock had his fourth kicking, screaming and hair-pulling fight with another child who had ”lied” to him, Mycroft sat his baby brother down and explained that most people weren’t evil or out to trick him, that they simply were stupid. Sherlock still hasn’t quite got over his outrage and strange disappointment at this. [And Mycroft still isn’t quite sure this was the right thing to tell him. True, Sherlock rarely tries to beat up people anymore, but on the other hand, he makes people want to beat him up quite a lot.]
He still almost never lies. He is so intently focused on facts, on unraveling how things really are, that the idea of muddling the facts on purpose seems unnatural and somewhat distasteful to him. Acting, though, isn’t lying. When he is in disguise - and he can slip into one at the blink of an eye - he’s not Sherlock anymore, he is a completely different person, and this other person can, of course, both feel, think and say things that would be, respectively, impossible, alien or untrue for Sherlock.
Sherlock, as himself, is both too obstinate and too obsessively rational to lie, even when he wants to, even when he knows it would be better for the case, or for himself. He has been considering trying to partly act, to see if this is could be a way of getting around his own mind enough to lie convincingly, but so far he hasn’t dared trying it for real, when it would really matter.