A bad book and good marketing won't work, the same way a good book and bad marketing will also not work. There is no choice in the matter that if you need to write a good book, you also need to have good marketing for it.
My main piece of advice would be don't worry about being published - just write a really good book, but also don't be afraid to write a bad book. Give yourself permission to fail, and don't be afraid. David Levithan