Can't control RB10 (and RB12) of the PIC32MZ2048ECG064 as a 'normal' GPIO
I believe that you must disable all other peripherals on the pin before it is connected to the GPIO latch. From the datasheet, RB10 shares the pin with several other fixed peripherals (i.e. non remappable). The peripherals tend to have control precedence in the order that they are listed on the datasheet pinout:


  pin 23: TMS/CVREFOUT/AN5/RPB10/PMA13/RB10


The datasheet also provides some information for configuring the pins for GPIO (page 238):


  The ANSELx register has a default value of 0xFFFF;
  therefore, all pins that share analog functions are
  analog (not digital) by default.


The JTAG peripheral (TMS) must be disabled. The analog input (AN5) must be set to use the pin as a digital IO using the ANSEL register (the datasheet has instructions on how to do this: section 28, page 412). The remappable pin (RPB10) will need to be cleared (I believe this is the default state). Finally the Parallel Master port will need to be disabled (PMA13 is an address line).