The kingdom of heaven is like
"When God in heaven shows himself to be king, it will be like"
like a treasure hidden in a field
"like a treasure that someone had hidden in a field"
and buys that field
He buys the field to take possession of the hidden treasure.