Yeah, there are a few discussions about this on the forums already. It's most likely a capacitance issue. When your phone is just sitting on a table and you touch the display, you may not create enough capacitance with the touchscreen for it to register as a touch (as opposed to resistive touchscreens which needed only physical contact but were less accurate as a result). Touching the body of the phone basically creates a common ground or voltage reference point for the phone, allowing your finger to create the needed amount of capacitance (in technical terms, no longer a floating ground). Whenever I touch the screen while the phone is lying on a table, I just always make sure to rest either my thumb or ring finger on one of the edges.
A lot of factors will also come into play---whether or not your phone is in a case, type of material the phone is resting on, the level of humidity in the air, even potentially the type of shoes you are wearing. This is why sometimes it works and sometimes it doesn't.