See my comment at https://www.lesswrong.com/posts/Mw9if9wbfTBawynGs/?commentId=uEtuotdC6oD2H2FPw on a closely related question.
Briefly, if instead of using performance on a test set to judge future performance on real data, or to compare two models, you instead use a formal Bayesian approach that looks only at the training data, the quality of the answers from this formal Bayesian approach may depend very crucially on getting the Bayesian model specification (including priors for parameters) almost exactly right (in the sense of expression your true prior knowledge of the problem). And getting it that close to exactly right may be beyond your ability.
And in any case, we all know that there is a non-negligible chance that your program to do the Bayesian computations simply has a bug. So seeing how well you do on a held-out test set before launching your system to Jupiter is a good idea.
Wild Speculation:
I am 70% confident that if we were smarter then we would not need it.
If you have some data that you (magically) know the likelihood and prior. Then you would have some uncertainty from the parameters in the model and some from the parameters, this would then change the form of the posterior for example from normal to a t-distribution to account for this extra uncertainty.
In the real world we assume a likelihood and guess a prior, and even with simple models such as y ~ ax + b we will usually model the residual errors as a normal distribution and thus thus loose some of the uncertainty, thus our residual errors are different in and out of sample.
Practical Reason
Also, a model with more* parameters will always have less residual errors (unless you screw up the prior) and thus the in sample predictions will seem better
Modern Bayesians have found two ways to solve this issue
Bayesian Models just like Frequentest Models are vulnerable to over fitting if they have many parameters and weak priors.
*Some models have parameters which constrains other parameters thus what I mean is "effective" parameters according to the WAIC or PSIS-LOO estimation, parameters with strong priors are very constrained and count as much less than 1.
What does “test-set performance” represent in Bayesian machine learning? In Bayesian ML:
I have seen people argue that we need a test-set to compare between two models M1 and M2 as we do not know what “the one true model” is. I don’t fully understand how “evaluating performance” on “out-of-sample” data helps us with comparing two models but isn’t this what the quantity p(M|D) is for?