Weapons decay with use (some decay VERY quickly) and clothing items decay randomly by you taking damage.
You can repair "broken" items using a repair tool and the appropriate skills in the crafting tree as long as there are small dots remaining for the item (if you hover over an item's icon, you can see it's decay status). Once an item has decayed completely, however, it's still not completely lost as you can then try to decompile it (once again, using the right tool and the right skills in the crafting tree). If you suceed in decompiling the item, you can craft a new copy of it using the code bits and fragments you've probably already noticed yourself picking up.
Collector's items, construct drops, and other special items, however, can't be decompiled after they have completely decayed and have to be collected again.