The attitudes of millennials ­toward marriage are getting harder and harder to understand.

This is a demographic whose economic prospects have never looked good.

They are coming of age at a time when college tuition is at record levels, student debt has surpassed a trillion dollars, houses (even after the bubble popping) are unaffordable, unemployment remains stubbornly high and wages have stagnated in recent years.

It’s no wonder they’ve been nicknamed “The Screwed Generation.”

So you’d think that if research shows there is something that could be a surefire way of improving their economic lot, they would grab hold of it like a life preserver. Well, you’d be wrong.

In fact, research has shown marriage to be responsible for the significant creation of wealth — yet millennials don’t seem interested. The average age of a first marriage for men is 29 and for women it’s 27. Many are simply not marrying at all.

Almost half of children born to women under 30 are out-of-wedlock births now, according to a recent study by Child Trends, a Washington-based research group.

Data collected by Ohio University’s Jay Zagorsky in 2005 concluded that those who remained single had slow, steady wealth accumulation — from less than $2,000 at the start of the surveys up to an average of $11,000 after 15 years.

By contrast people who stayed married showed a sharp increase in wealth accumulation after marriage, growing to an average of about $43,000 by the 10th year they were together.

According to Zagorsky, married people increased their wealth about 4 percent each year just as a result of being married, with all other factors held constant.

In other words, it’s certainly true these days that people who get married are more likely to have money in the first place. But even controlling for that it seems that tying the knot gives people at all income levels an advantage.

In part, that is because of economies of scale — you only have one place to maintain. But why doesn’t that advantage work for cohabitating couples?

Well, for one thing, many couples living together are doing so precisely because they’re not sure if the relationship is going to last.

Meaning that men and women are less likely to sacrifice for the greater economic good of the relationship if they have one foot out the door.

Indeed, young couples often say they are ready to have kids together but are not sure about the whole walking-down-the-aisle thing.

A 28-year-old woman recently explained to NPR that she didn’t even consider marrying the father when she found out she was pregnant.

“It changes the dynamic of the household,” she says. “I had a friend who put off her marriage. Got pregnant, and she’s like, ‘Let’s just wait, ’cause we don’t know if we’re going to be able to make it through this.’ ”

You don’t know if you’re going to make it through raising a child together, so you have the child but you don’t get married?

It’s like a recent episode of Judge Judy where one of the claimants tells the judge that he’s not in a “serious” relationship with the other one.

“You have a kid together. How could it not be serious?” she asks with typical head-smacking obviousness.

Of course, the biggest economic (and social) benefits of marriage are the ones that are passed on to kids. Children of married parents are more likely to graduate high school, less likely to go to jail and more likely to delay sexual activity.

And, of course, children of ­unmarried parents are more than five times as likely to live in ­poverty.

Looks like The Screwed Generation is raising the really screwed one.