Burying valuables in the ground was a common way of protecting them in ancient times. A past owner of a field had done so, and the present owner was unaware of it. The parable assumes that someone buying the field was entitled to anything buried in it. The point of the parable is the joy in obtaining the treasure, and only secondly the costs to the buyer. The parable of the pearl makes the same point. We should be filled with joy at the prospect of obtaining eternal life, and consider the cost secondary.
To enter the kingdom of God is beyond all that one could ever hope for. Its value is beyond all ability to pay for it. This is in fact what Christianity is all about. To be a Christian means to be reunited with God through Christ. This is of greater value than everything else in this world.
The emphasis of these two parables is not on how much he gives up but on how much he finds—and how happy about it he is. When we find the gift of salvation, we joyfully give up everything else in order to possess it.