I think there are two parts to answering this question. First, you should make sure that the teacher is incompetent and not merely unlikable. Second, if the teacher is incompetent, there are a number of options available to avoid studying with them.
With respect to the first point, it is important to note that a teacher can be unlikable, and perhaps even appear ignorant (to students), while still being great at his or her job: making sure you learn things. For example, group work and peer instruction are known to be effective teaching strategies. At the same time, they are also quite unpopular with students, and some students even take the view that the instructor is not doing their job when these strategies are applied (even though the outcome may be very good). Professionalism and teaching style are very personal traits, and I've not seen any evidence that they have strong impact on student learning outcomes. It sounds like maybe your personal dislike of the instructor is clouding your judgement about whether they could be an effective teacher. A teacher has only one job: making sure you learn things. If they can do that job effectively, then it shouldn't matter whether you like them or not.
Talk to students who have finished the course, and find out what they've learned. Often its only after such a class is complete that students realize they've learned a lot. If you know you'll get a lot out of the course, then you should probably take it even if you don't like the teacher.
On the second point, if the teacher really is incompetent, and former students are in strong agreement on this point (and they really don't seem to have learned anything about the subject), then you do have some other options:
- Many schools will let you take online courses from other universities for credit. For a chemistry course with a lab, this may not work out, but otherwise this might be your best bet. You can shop around, find an instructor that you like, and still get credit for the course.
- If the instructor is genuinely incompetent, you could speak with the school administration, and make a formal request for a different instructor. Often your request will be ignored, but I have seen this result in a new instructor being assigned once. Again, it is important that you make sure this is an instance of incompetence and not unlikeability. This is a serious step, and could have implications for the instructor's job (especially if they lack tenure).
- You might be able to wait it out, and take the class with someone else. At the university undergraduate level, this can be the easiest solution, provided that the course is not a major prerequisite in your program. At the high school and grad school level, there may not be an alternative instructor in that subject area, so this may be infeasible.
- Attend the class, but plan to use external resources to study. Consider forming a study group at the start of the semester, and meeting several times a week to talk about class material. Use online courses like those offered by MIT's Open Courseware, or any of the MOOC companies, to supplement the lecture material, and shop around online to find the best textbook at your level for this topic. You can make sure that you've learned the material well, even if your instructor is unable to help you learn it.