That's not what it says. It says to one group it is given to know certain things, and to another it is not given. One group is given a gift, the other is not. You say it's because one group has behaved better than the other, and therefore merited it. God always and ever says one is given something because of election, and not because one has done either good or evil.
Yes that is what it says. There were two groups. One wanted to learn of God, one was self righteous and didn't see their need for salvation. Stop looking at it through Calvinism.