Based on the hint from @wip, I started to research and found a wonderful discussion. They have shared so many reliable sources but everything is Japanese and it's very very long so I'll pick up points relating to this question.
About kanji variation. First of all, there were hundreds of variations of kanji of coffee (as a form of ateji) at least in Japan. You can confirm these variations thanks to an artwork by a woodblock printmaker, Okuyama Gihachiro.
(Photo by Mitsutoshi, Watanabe, at a coffee bar TOM in Yoyogi)
Most of these variations are based on mimicking sound as the way Western people called it, 'coffee', 'Koffie' or others. For example, Japanese first coffee shop was named "可否茶館", which is surprising because "可否" (another kanji form of coffee) is now widely used as the meaning "possible or not".(Nobody in modern Japan would think this kanji as coffee. But in fact the pronunciation of "可否" "kahi" is similar to 'coffee' even for Japanese, so it's possible as ateji.)
We could guess that this enormous variety shows coffee got popular in Japan rapidly and concurrently.
Which is the original, 咖啡 vs 珈琲? 咖啡 and 珈琲 resembles each other. So it's natural to understand either one mimicked the form of the other.
The kanji 咖啡 is seen at least in 1819 in a dictionary edited by Robert Morrison(from UK). However, coffee might not be so popular for Chinese at this moment because China was tea giant on the earth. (Note that UK became a big tea consumer and China became a big tea supplier in exchange for opium in this era. We could guess UK was eager something to sell to China in order to minimize trade deficit. Coffee might be one candidate.)
The first 珈琲 was coined by Udagawa Yōan (Western learner of Japan). He has written the first thesis about coffee in Japan in 1816 titled "哥非乙説". (Here another variation "哥非乙" as 'coffee' shown up) Later, the first kanji 珈琲 surely appeared in his another book(page33, column2, line1) by the time he died 1846.
Assembled these information, there is no evidence about the original. But we could suppose 咖啡 was the original because
(1) At the time Robert Morrison was editing the dictionary, Udagawa Yōan was early of 20 ages. It's unlikely Morrison referred to information by Japanese young man.
(2) Udagawa Yōan was Western learner and he was familiar with Western sources. The dictionary by Morrison seems to have been imported to Dejima. So it's probable for Udagawa to have checked Morrison's work.
So, why 口 radical? Here is an interesting fact. Especially in old Vietnam, people seems to have had a custom to put 口 radical for phonograms. For example, 𠸄咭唎 as well as 英吉利 means 'England'. Here 口 may indicate 'speaking'. (Note that old Vietnamese have used kanji as writing system, called Chữ Nôm.) Phonograms is useful for loanwords. That means it works in the similar way as katakana.
First (modern) coffee in China seems to have been introduced to Yunnan province, which is southern China and near to Vietnam. Considering modern Vietnamese are prominent coffee lover in Asia, Vietnam may have played a big role to spread the kanji 咖啡.
So, why 王 radical? As @Kantura, @Leebo and @dROOOze mentioned, this is actually 玉 radical, meaning jade. "珈" is also pronounced as 'kamikazari', meaning 'kanzashi'(kind of hair accessory). "琲" means a string to bind jades. Thus the kanji 珈琲 reminds us the hair accessory with jades. That's why people admire of his cool and playful selection. People also imagine that he would have known the coffee tree and beans. You can check the image of this article about the relation of coffee beans and kanzashi.
I'm not sure why he would transform the (probably existed) kanji intensionally. Maybe just by his playful mind. However, there is another surprising hypothesis. This source is from a book "珈琲遍歴" written by Okuyama Gihachiro(the woodprint maker). He wrote in a book
珈琲の王扁は、その物の産する土地が遠い所の場合に王扁をつける様だ。
As for 王 radical like in 珈琲, it seems to be used to tell that a place which thing/object was made is far from here.
Udagawa may have just followed this rule.
So, why 珈琲 has won in Japan? As I showed, there were so many kanji of coffee in Japan as well as 咖啡. But 珈琲 has won this survival after all. This reason remains unknown but according to the discussion, Japanese script reform may have given a big effect on this battle. (Note that in this era, the relation of China and Japan were going bad. It's possible the government intensionally avoided using Chinese way.)