Is it ethical to withdraw a paper after acceptance in order to resubmit to a better journal?
It is not ethical to withdraw a paper that has been accepted. Journals, editors, and reviewers invest time in the publication process. To withdraw a paper after it has entered this process is a waste of their time. While the legal ramifications of is behaviour are probably limited, it will result in bad feelings.

As for not having the money to publish. Assuming the journal fees are available prior to submission, and reputable journals make their fees known, then if you don't have the money, then you don't get to submit. If they have a paid expedited service and you are worried about the back log, then ask up front. The only case that it might be acceptable is if he review process drags on for so long that your funding ends.