It is said that the poor are not necessarily unhappy.

Literal

Poor person [subject-が] necessarily unhappy [explanation-なわけではない] [quotative-と] is-said.

~と言われている marks the statement as hearsay or common wisdom. ~わけではない is the partial negation 'it's not that...' combined with 必ずしも for 'not necessarily.' A layered construction expressing a reported nuanced view.