We can swap mouse buttons by editing the registry value SwapMouseButtons under the registry key HKEY_CURRENT_USER\Control Panel\Mouse. To swap mouse buttons for the current user we need to set its value to 1. This makes the right button the primary button.
The same thing can be done from command line using the below command.
reg add "HKEY_CURRENT_USER\Control Panel\Mouse" /v SwapMouseButtons /t REG_SZ /d 1
If prompted to overwrite the existing value, enter Y to confirm. Sign out and sign back in for the registry change to take effect.
To restore the left button as the primary button, set the value back to 0 and sign out and sign back in again.
reg add "HKEY_CURRENT_USER\Control Panel\Mouse" /v SwapMouseButtons /t REG_SZ /d 0
To configure this from GUI, you can follow the instructions here: Swap mouse buttons