My boss wants to send me to a costly external training (all cost covered by the company). I like the topic, and I believe this training could be interesting and beneficial. Unfortunately however I generally do not really feel myself happy at the company. I get tasks that I am able to solve only with enormous struggle, and sometimes I am not able to solve them at all. So I decided to wait for my next project, if it turns out to be as hard as the most recent ones, I will quit. The training in question might be beneficial, might improve some aspects, but with a project as complex as ours definitely can't solve everything. If I take the training and a month later I quit the job, I feel myself bad (and unfair). On the other hand I might get just lucky, maybe this next project is not as hard as the most recent ones (earlier I had some pleasant ones) so I can stay and work within my comfort zone, and then the training might come handy... So my question is how to explain this situation to my boss.
As you've been with the company for over two years and have no actual plans to leave, then I don't see anything unethical with going on a course which is mandated by your boss.
I'd feel a little differently* if you had something else lined up or concrete plans to hand in your notice soon, but right now, although you're dissatisfied, you're sticking with the company. You might find a job soon after and so be it, that's life and business - but it's just as likely that you'll stay for another 6+ months.
To firm up this opinion is the fact that this training may be beneficial to how you feel about this role - it's highly plausible that your boss knows full well you're struggling and/or dissatisfied and is sending you on this course for precisely this reason.
So, in conclusion, go on the course and see what the future brings!
*I should point out that even if it were a little unethical, I'm not actually sure what you could do differently. It's a pretty common rule to never ever show your hand until you're absolutely ready to hand in your notice, anyway.