Light always travels in a straight line. So the light from the top of an object passes through the pinhole, continues in a straight line, and ends up at the bottom, on a screen. Similarly the light from the bottom of the object travels through the pinhole, continues in a straight line, and ends up at the top, on the screen. Hence the image looks inverted.
other reason
Essentially, because the aperture (hole) is so small, it bends the light in a manner that inverts the image. It is not just upside down, but it is also a reversed image. If you can imagine a beam of light hitting the aperture opening as coming in from the shape of a equalateral triangle, when it enters the lens (aperture opening) the beam is reversed and an equal sized angle of light is projected on the film plane. The size of the image is determined by the focal length of the aperture, but generally for an aperture size of .256, you will have a focal length of about 3 inches (77mm).