Why viminfo setting doesn't work in VIM

That's easily explained. You have

:set nocompatible

after :set viminfo. The former is a special, important option, which affects others; from :help 'compatible':

This is a special kind of option, because when it's set or reset, other options are also changed as a side effect.

The solution is easy: Move it to the start of your ~/.vimrc, or drop it altogether, as nocompatible is implied by having a .vimrc file.