Back in the 1990s I read a book called Annotated Art (1995) which discussed, among others, the Mona Lisa. It suggested that the mystery of the smile was due to the background scenery in the painting, but also said "we will never know for certain". Not satisfied with that I had a look at it myself and I figured it out almost immediately. I can't believe it remained a mystery for hundreds of years!
When you look at the smile you can see some shading around the corners of the mouth that is more prominent on the right-hand side than the left (as we are looking at it):
However, when you look between her eyes, in your ‘mind’s eye’ the shading becomes part of the smile, and it appears that she is smirking out of the right-hand side of her mouth. Your mind perceives the smile to have a shape as indicated below:
This smirk disappears when you look back at the mouth because the shading and the outline of the lips become clear again.
Leonardo adds to this effect with noticeable lines of shading on the face, which mark out a contour that is higher on the right-hand side than on the left, and continues into the mountains in the background:
This shading, plus shading around the eyes, and the mountains and lakes which are higher on the right-hand side than on the left, all combine to provide a visual ‘pull’ towards the upper-right of the picture that complements the effect of the shading around the mouth:
(The point about the mountain and lakes being at different levels was made in Annotated Art)
Finally, I believe that the shading below the mouth provides a visual ‘pivot’ that draws the mind’s eye to the base of the smile to assist in the effect:
It was Leonardo’s genius that he understood how the mind perceives imagery that is just outside the focal point of vision. Perhaps a “Mona Lisa App” could be developed that could achieve this effect on any portrait.