Consider a string that is clamped at and (i.e ) undergoing traverse vibrations. And you would like to know the motion of the string.

Maybe you know a priori that the solutions are sinusoids but you have no information on its wave number.

So you start trying out every single possibility of the wave number.

The important thing to understand here is that If there werenâ€™t any boundary conditions that was imposed on the string then all possible sinusoidal wave would be a solution to the problem.

But the existence of a boundary condition acts as a constraint and restricts the total number of possibilities.

Fun Sidenote:

Perhaps you have stumbled upon the word ‘quantization’, ‘quantized’, ‘discrete energy states’ when people talk about atoms. If not, you will most probably hear it somewhere when you are taking an undergraduate class in physics.

If you have an electron in a hydrogen atom, there are only specific energy levels it can be observed to occupy when its energy is measured because the electron is trapped in the atom which is a type of Boundary condition -> restricts the total number of states possible -> identical to the string scenario -> leads to quantization

But if the electron is unbound or there are no boundary conditions, the electron can in theory take any energy state it wants. You cannot have quantized states if you do not have boundary conditions.