The background sprites are used for the map editor, the map only uses sprites from index 0 to 255. The foreground is an extra sprite layer that can be used with spr() function. With spr() you can show sprites from 0 to 511, which 0 to 255 are from background and 256 to 511 are from foreground.