Write your book, then rewrite it. And edit it. And edit it again. And edit a third time, at the very least. (Yes, almost all writers, even professionals, have to do this!)
Once you're positive it's in the best condition it could possibly be, you send out a query letter and one page synopsis to agents - and then cross your fingers! If it's a great idea, one worth publishing, and executed correctly, you'll find an agent willing to represent you eventually. Don't let rejection get you down.
Most of all though, keep writing and keep learning. Even if your first effort doesn't sell, that just means you have more to learn, that's all.
Best of luck to you!