For example, crumbs from months of working lunches can eventually interfere with your keyboard’s key switches, preventing certain keys from registering (not to mention that a dirty keyboard is, well, gross). Dust and pet hair can build up around your computer’s vents, and on internal components, preventing the cooling system from working properly. This can shorten the life of your computer’s components over the long term, and can also cause seemingly random lockups and shutdowns when your Mac overheats. Without regular cleaning, a Mac’s internals can get so dusty that components—such as this video card—may stop working properly. You probably won’t be able to figure out why until you open the case.
Luckily, keeping your Mac clean doesn’t take much effort. You can use a damp (not wet) cloth to wipe down your Mac’s exterior, and compressed-air canisters work well for clearing the dust from your Mac’s vents and loosening much of the junk that’s fallen into your keyboard. (Don’t use a standard vacuum to try to suck away dust, as static electricity may damage your computer. If you want to use a vacuum, you need a special anti-static model.)
If you’ve got a Mac Pro or an older Mac tower, open it every few months and make sure there’s not a significant amount of dust inside. And avoid eating over your keyboard or typing with sticky hands.
If you have a laptop opening it up is not as easy unless you know what you're doing. You can still use compressed air and a damp cloth to take care of the exterior.
Source: Macworld.com