os.listdir()
will give you a list of the files in a directory.
random.choice()
will pick a random item in a list.
Once you have the random file name you can then open it in the UV/Image Editor.
import bpy, random, os
imgdir = '/path/to/images'
imgfile = random.choice(os.listdir(imgdir))
bpy.ops.image.open(filepath=os.path.join(imgdir, imgfile))
new_image = bpy.data.images[imgfile]
# show the new image in the image editor
for area in bpy.context.screen.areas :
if area.type == 'IMAGE_EDITOR' :
area.spaces.active.image = new_image