Fixing Keyboard “Type" Problems
Macs have one of three different physical keyboard “types,” which Apple calls JIS (for Japan), ISO (used in Europe, for example) and ANSI (used in the US). ISO has one key more than ANSI -- it is located between z and shift -- and JIS has quite a few differences.
Sometimes a machine will forget which type keyboard is attached, with the result that certain keys get transposed from what the user expects. For example, if the shift level of the numbers row on your US keyboard produces ! " # $ % & ' ( ) 0 = ~ instead of the normal ! @ # $ % ^ & * ( ) _ + , your machine thinks you have a JIS keyboard instead of ANSI.
The fix for this may be to run the Keyboard Setup Assistant again. Sometimes there is a button for "Change Keyboard Type" visible in System Preferences/Keyboard. If not, you can try trashing the file
/Library/Preferences/com.apple.keyboardtype.plist
Another possibility may be to open Terminal and type:
sudo open /System/Library/CoreServices/KeyboardSetupAssistant.app/Contents/MacOS/Keyboard SetupAssistant
Sometimes one may have to follow the procedures in the SMC Resetting instructions:
https://support.apple.com/en-us/HT201295
If none of those work, this Karabiner option may be helpful:
For reference, this doc shows the different keyboards supplied by Apple around the world: