means that
financial gain should not be the sole reason for marrying, although financial security may be considered desirable. The saying reflects a pragmatic attitude towards marriage.
Imagine a case where money shouldn't be your main criterion in choosing someone to marry, it is good though, to marry a person with sufficient means for a comfortable…; then “Never marry for money, but marry where money is” fits well.