Why would a compact fluorescent lamp randomly turn off?
It's impossible to say for sure without inspecting the lamp, but it sounds like a bad CFL. Have you already checked to be sure that the bulb is screwed in securely?

You could use a multimeter to check for continuity through all of the wires to the socket (which can be difficult when trying to find an intermittent connection since digital multimeters displays don't update instantly, a meter with an audible continuity tone would be useful). 

However, If this is a standard lamp with a screw-in CFL bulb, there's a simple test you can do that only costs a couple dollars (or may even be free if you have a spare CFL bulb in the house or can "borrow" one from a different lamp):

Put a new bulb in the lamp and see if it works.