From an applied functional analysis course where the weak formulation was covered, I think I have a high-level understanding of the concepts that are involved.
To derive a weak formulation for a PDE, the procedure I have learnt is to multiply both sides of the PDE with a so-called test-function, and integrate over the domain. These test functions should be in some kind of space, and I'm not sure how to choose this space (I might have forgotten this, as we dealt with a lot of topics in these courses).
Of course, in order for the weak formulation to have meaning, the test functions should at least have enough derivatives in the weak sense (for this, Sobolev spaces are often used). However, often, there are restrictions added that seem to be related to boundary conditions on the PDE. For example, for Dirichlet boundary conditions, the space is often chosen to be a Sobolev space which is zero on the boundary.
I can see that this is helpful when one wants to apply Green's theorem to make the expression more symmetric (or to minimize the order of the derivatives in the expression), but it seems weird to make this kind of modifications to the test function space just based on what is convenient during. How can we be sure we are not throwing away interesting solutions by changing the test space in such a way?. Or is the test space based derived in some other way, and is the zero-ness of the test functions just a coincidence that happens to be useful?