Search engine optimisation is about presenting your website in a way which search engines can understand it better, and hence rank it better. The search engines are aware that people actively optimise their websites so that they can get better rankings and in a lot of cases, they give hints on how to do this effectively.
However, there is another side of search engine optimisation which is to try to trick the search engines into giving higher rankings than the website naturally deserves. The methods used are known as Black Hat techniques, as opposed to the preferred White Hat methods.
Black Hat techniques can result in your website being penalised in the rankings, or in some cases will get your website banned from the search engines altogether if you are found out. The search engines aren't there as a service to promote your business, they are there to make money. In order to do that, they need to give their visitors the best results for their searches. So naturally, they do not take kindly to people tricking their software into giving them better rankings if it gives their visitors low quality search results.
So, the golden rule, is not to use black hat techniques.
A problem arises, however, because there are so many rumours and urban myths going around about how to get better rankings, and a large proportion of these myths are either wrong, or are recognised black hat techniques which could get you banned if you use them. If you accidently manage to get yourself banned, it can take several years to get your website taken off the blacklist. So, it's quite a serious mistake to make.
The first mistake a lot of people make is keyword stuffing. The myth is that in order to get good rankings, you have to repeat your keyword over and over again on your page. This is based on the idea that you need to get your keyword into your page and preferably a few times. Getting your keyword into your page once is unlikely to produce a significant ranking for that keyword. But using it a few times will produce better results. The assumption has been that the more times you use the keyword, the better your rankings will be. But this is just not the case. Search engines aren't that stupid. They know when you're just listing your keywords and they know when you're just repeating yourself.
Use your keywords intelligently and use them appropriately. It's not just about the quantity, it's about the quality too.
You'll often see websites that just have a list of keywords at the bottom of the page. A frequent trick is to try to repeat the keyword in a phrase with all the local towns. There may be 3 or 4 lines of something like "Web design in Gloucester, Web design in Cheltenham, Web design in....". This is pointless and may get their site penalised. For a start, it's likely to be completely ignored. It's obvious to the search engines what they're doing here, so they are not going to consider it in their search algorithm. If they do consider it, it will be to mark the site down as a poor quality "page of lists". Nobody wants a page of word lists in their search results, so search engines try not to provide them in their results.
A black hat technique that some people attempt is to make some text the same colour as the background. If you write a paragraph using your keywords loads of times but make the text colour the same colour as the background, the visitors won't be able to see it. The text will still be there, just hidden. That way, you can present a "normal" page to your visitors, but have some hidden text that only the search engines will see. However, this is a very old technique and search engines spot this very easily and will penalise you for it.
Another myth is about hiding keywords in your "alt" attributes on your images. Every image needs a text description and this is used by the search engines in their ranking algorithms. But again, if they notice that all of your images are just repeating your keywords, this will count against you. The text description should actually describe the image that the visitor sees. Just listing your keywords doesn't help anybody and may result in lower rankings. By all means, use your keywords when specifying the image descriptions if it is appropriate. But don't just blatantly stuff your keywords in there.
Some people will even create a tiny 1 pixel size image that nobody will notice on the screen, just so that they can put their keywords in the description for it. This is an easily spotted black hat technique which will result in your site being severely penalised.
There are many other places that keywords can be hidden which the search engines will spot. The general rule is to use your keywords frequently, but appropriately.
There are many other black hat techniques out there, most of them are quite technical and involve presenting different data to the search engines than to normal visitors. The ones given here are just a few examples which you might not have realised would count against you.
Search engines spend billions of dollars (all the big ones are American) on employing the cleverest people in the industry to try to catch out the people using black hat techniques. Their budget is bigger than yours, and their people know more about their stuff than the rest of us could possibly imagine. They will always beat you if you try to trick them.
I'm not saying don't use search engine optimisation, I'm just saying be careful about the techniques used. The philosophy of search engine optimising your site should be to improve your rankings by creating the website that the search engines want to see. It shouldn't be about tricking the system into giving you the best rankings.