Rav Hirsch points out that the king of S'dom, who had been saved by Avraham refused to acknowledge the good that he had done and what thanks he owed him. He instead tried to buy his position back. This shows the character traits that caused the destruction of the five cities.
Melchizedek, on the other hand, came to acknowledge the miracle that Hashem had performed for Avraham and to thank him and bless him for putting himself at risk. He also came to show the appropriate hospitality to the weary warriors.
Even after Melchizedek comes to thank Avraham and to refresh the weary warriors, the King of S'dom takes the wrong idea and thinks that Avraham can be bribed into giving him his due. The sentence after, shows that he totally does not understand the idea of הכרת הטוב, gratitude.
Lech Lecha 14:17-18
These two verses show a striking contrast. The King of Sosom, who must
have felt very humiliated, and still more deeply indebted towards
Abraham, not only allowed him to undertake the pursuit alone with his
little band without joining him, but after the victory had been won,
comes out to meet him entirely as a King, thinks it is already a
sufficient honour for Abraham to be met on equal terms as King to King
"in the valley שוה". And still he comes to beg. To ask for favours, to
"demand", is what a King of Sodom understans, but to refresh the worn
out, famished victors with a piece of bread, with a drink of wine,
does not enter the head, forms no part of the code of manners of His
Majesty of Sodom! On the other hand, Melchizedek, King of Salem, who
really had nothing to do with the affair, had bread and wine brought
out, but then he was also a priest to the Highest G0d. So that even
amongst the polytheistic nations the conception of an All-highest G0d,
אלוקא דאלוהא, a G0d of gods had not become entirely lost.
But even so, here at once, two points become evident. (a) where this
G0d does hold sway the place became שלם, a home of peace and
salvation, (b) is conditional on צדק, on justice, righteousness, on
the just moral behavior of men.