How do I tell my boss I got a new job?
This can depend on your firm policy and culture of the firm. Your firm may require his approval to finalize the move. You need him to know you're unhappy with where you are and what you're doing, but I would get as hard a guarantee that the new job is yours as you can before you inform your boss that you intend to make the change. It also may not be official policy, but your current boss may have the influence to stop your move.
When it's time to tell him, you see him face-to-face (if possible) and you tell him as soon as possible, but when the move is as finalized as can be, and not before. If you tell him before the move is as finalized as you can make it, you may wind up replaced without a place to land.
If he's willing to let you go, or he has no say in the matter, he may be a little disappointed, but he'll take it like a champ.
You'll also want to make yourself as available as your new duties will allow to consult with your replacement if you want to ensure your move does not leave you with a bad reputation.
Will it be perceived as I changed because I was not capable of doing something?
You already have the new job. If the question ever comes up in the future, you tell them what you've told us.
The entire team moved to a different project and I d[id]n't find the
current work challenging.
It wasn't what you were originally hired to do, so you moved. No one will consider you poorly for it.