Locking the hotbar will mean that clicking on an item there won't select it (which will happen if unlocked).
Locking it is useful for boss fights - if you're clicking around trying to avoid/attack the enemy, you won't accidentally click something on the hotbar and switch your weapon.
Personally, I leave mine locked all the time, and use the scrollwheel or 1-0 to select an item in the hotbar.