Hello, I am going to tell you of a common issue for your symptom. The EFI relay in the main relay box under hood stops working intermittantly. Dont just change it, I'll tell you how to diagnose it easily. When the truck wont start, Turn the ignition switch to the on position and look for the check engine light in the instrument cluster, if it is lit up the EFI relay is not your issue but if it dosen't light up get a new relay.
Now for a second poissibility, If the check engine light comes on with the key on, watch what happens to the light when you start cranking the engine over, if the check engine light dose not shut off while you are cranking the engine you likely have a bad crankshaft position sensor.
I hope this helps you. Mike,