weight function
When you say two functions are orthogonal, you have quietly chosen a way to multiply and integrate them. The weight function is that hidden choice made explicit: a positive function w(x) that tells the inner product how much each point of the interval should count. Two functions f and g are orthogonal with respect to the weight w when integral from a to b of f(x) g(x) w(x) dx equals zero. Change the weight and the same two functions may no longer be orthogonal.
Where does the weight come from? It is read off the self-adjoint form of the Sturm-Liouville equation: the coefficient w(x) multiplying lambda y in (d/dx)(p y') + q y + lambda w y = 0 is the weight. It is no accident — when you derive orthogonality by integrating the equation, the term that survives is integral of (lambda_m - lambda_n) y_m y_n w dx, so the eigenfunctions come out orthogonal precisely against w, not against the bare measure dx. For the Fourier sine basis w = 1; for Legendre w = 1 on [-1, 1] but for Bessel w = x and for Hermite w = e^{-x^2}.
Practically, the weight is what you must remember to insert in every projection. To find the coefficient of an eigenfunction in a generalized Fourier series you compute integral of f y_n w dx divided by integral of y_n^2 w dx; forgetting the w gives wrong coefficients and a series that does not reconstruct f. The weight also has physical meaning — in a vibrating membrane of variable density, w(x) literally is the mass density, so orthogonality with weight is conservation of a weighted energy.
Hermite polynomials H_m and H_n satisfy integral over all of R of H_m(x) H_n(x) e^{-x^2} dx = 0 when m is not n. The weight e^{-x^2} is essential: with weight 1 the integral would diverge, and the polynomials would not be orthogonal at all.
Each classical orthogonal-polynomial family is defined by its weight as much as by its equation.
The weight must be strictly positive on the open interval; it may vanish only at singular endpoints. A sign change in w would destroy the inner-product structure and the reality of the eigenvalues.