Think of it in evolutionary terms. There is physical evolution, but there's also mental evolution, moral evolution, legal evolution and so on.
We also see education as being useful, yet education seems to not teach many critical things which we often leave up to parents. Yet, many parents do not fully teach essential morals or lessons. It wasn't that long ago that the only real kind of formal education was a sort of religious education.
Religion in a way, carries forward crystallized values that people felt were important enough. You can look at all the religions around the world and identify the various elements of how those people behave. Is the way they behave useful, logically?
Not everyone is a scientist or a computer programmer, many people do not invest heavily in their minds. We might think that religion only served a purpose 500+ years ago, because it was an inverted solution to a surveillance state, letting people police themselves from within their own minds when external surveillance apparatus was basically not sufficiently viable.
I would argue some, but not all religions, still offer value as they bring forward crystallized behaviors that serve an actual purpose.
We've all seen how easy it is for people to get manipulated, become violent, etc. That seems to happen even if they aren't religious. So, if the people who are most susceptible to manipulations are pre-manipulated into a positive format that encourages them away from violence, that doesn't sound useless.
It's true that religion has been involved in many wars, but not all of those wars were for religious ends, even if religion was used. If religion wasn't used, it might have been something else. Societal structures and law enforcement have advanced a lot since then.