I've linked one (iSH) in my comment. It really does run most completely unmodified x86 binaries for Linux, including CPython and Java.
aShell [1] is very similar. It takes another approach – it compiles POSIX C source code to WASM and runs that using iOS's JIT-enabled web engine, which gives it much better performance than x86 software emulation. There's another one that uses lldb to interpret LLVM IR. In other words, if Apple doesn't want that type of app, they sure have been explicitly enabling the use case for a long time now.
> And the restrictions are mostly in place; otherwise, for example, there would be apps that allowed you to download torrents, or do other forbidden activities.
App store reviews don't exist to "prevent forbidden activities" in the legal sense; they are there to maintain their walled garden ecosystem financially, as well as protect their platform and products from reputational or legal harm.
The issue of legality and passing the App Store review process are largely orthogonal: Just like you can already do plenty of illegal things using stock iOS (e.g. writing threatening emails, downloading copyrighted material using WebTorrent etc.), you can do infinitely many legal things using Turing-complete computing as enabled by first and third party apps on iOS.
Now if you start offering an app that features a big button labeled "click here to dynamically load software facilitating copyright infringement", and Apple distributes it in their App Store after having reviewed it, that could get them into a tricky situation; offering a full-featured browser or OS emulator very likely doesn't, given that Google has been allowing these types of apps in their Play Store for more than a decade now.
[1] https://holzschu.github.io/a-Shell_iOS/