If I understand correctly, all other palette-changing software works out ok, just Windows 3.1 was acting odd. So manually writing code to probe palette indices might not reproduce the issue.
From existing games and demos that utilize the palette register: Wolfenstein 3D (uses REP STOSB palette updates in screen fade-in and fade-out), Kukoo 2 demo (reprograms the palette register mid-frame), Wiering's Mario (does palette fading traditional way), Jazz Jackrabbit (does palette cycling animation e.g. in waterfalls) and One Must Fall 2097 (multiple screens with different palettes)
If those don't show any issues in DOS, then it should definitely be something that only manifests in a very specific code pattern, maybe due to the 2D GUI blitting acceleration.
Board capacitor recapping in order?