There is a lot of such code. Every day you use dozens of websites which need this. Although these days they're mostly written in JavaScript and sometimes Flash's ActionScript, but the general idea remains the same.
(Remember that one of the primary uses of Java was for applets in websites – similar to Flash later and JavaScript today.)
There are also many more architectures than "PC and mobile". Over the past two decades, PCs have used a few dozen different CPU architectures – for example: 68000, PowerPC, x86, amd64, Alpha, SPARC, ARM, ARM64 – and that's just the popular ones.
So that creates problems in distributing the compiled programs.
With native code, every such website's owners would have to distribute many different versions of the same program – one for every CPU architecture (remember, it's not just two), or maybe even for every OS × CPU combination (as different operating systems have different services, different APIs, different calling conventions on the same CPU).
(Even within the same architecture, many programs compiled for Intel i686 won't run on i486 even though that's technically the same x86 – but with different features. For example, Debian Linux compiles everything for i486, so it won't make use of any modern CPU features which means programs may be a little slower. On the other hand, Arch Linux is compiled for i686, so it won't run at all on an old i486 CPU.)
With bytecode, Sun/Oracle can distribute JVMs for all architectures, and webmasters don't need to do anything other than that – they only need one .jar file for everyone.