The main problem with the pinhole camera is that the area of the pinhole is very small, so only a small fraction of the incoming light is captured. To cope with the faint light coming from the pinhole, the photographer requires either very bright illumination of the subject, or very sensitive sensors, or very long exposure times.
That is why we have lenses: a lens is "harvesting" the light from a much bigger area when compared to a pinhole, so a photo-detector will have a much easier job with capturing the image.