Love God and your neighbour, and you will find you way into the Kingdom. That is how Jesus answered a similar question about how to gain eternal life at another time when he went on tell the story of the Good Samaritan. It is difficult. People can try to be fair to others. Economic systems can be made more just.
People can voluntarily give away much of what they gain.
But it is hard for most people not to think that they deserve what they have. After all they have is so often seen as what they are 'worth'. Such dangers are real because of human pride, which makes it difficult to avoid the traps of seeking wealth. We are not then saved from the dangers of wealth by our own efforts, even our moral and spiritual efforts, but by the grace of God. For God , not for us, all things are possible.