For best performance it's important to keep your Mac clean.
This means taking care of the insides as well as the outside.

Keep your desktop clean and organized.
OS X treats each item on your Desktop as a separate window. That means every file and folder you store there uses memory and CPU resources. The more powerful your computer is, the more items your Desktop can hold without noticeable effects. But eventually you’ll see more spinning beach balls and slower Finder actions, so it’s a good idea to occasionally straighten up.

Watch the crumbs and dust.
Many people underestimate the importance of keeping the physical structures of their Macs clean. Of course you want to keep coffee, soda, and other liquids from spilling into your keyboard or on your MacBook, but other, less obvious, substances can gunk things up.

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