SEO is completely legal. There are various SEO strategies, most fall into (2) categories. "White Hat" SEO and "Black Hat" SEO. White Hat follows Google Strategies and Recommendations while Black Hat are tactics that are frowned upon. Stick to White Hat, you can't go wrong.