The dimensions are shown in the setting descriptions.
Game Screen BG: max 448x256px
Second Screen BG: max 400x240px
I’d recommend using exactly those sizes, but smaller images work too.
Also, it’s best to pre-dither the images, otherwise gradients may show visible banding on the 3DS.