I actually prefer Matthew Henry’s comment on these verses better than John Gill’s.
Pro 22:26 Be not thou one of them that strike hands, or of them that are sureties for debts.
Pro 22:27 If thou hast nothing to pay, why should he take away thy bed from under thee?
Proverbs 22:26-27 Henry
We have here, as often before, a caution against suretiship, as a thing both imprudent and unjust. 1. We must not associate ourselves, nor contract an intimacy, with men of broken fortunes, and reputations, who need and will urge their friends to be bound for them, that they may cheat their neighbours to feed their lusts, and by keeping up a little longer may do the more damage at last to those that give them credit. Have nothing to do with such; be not thou among them. 2. We must not cheat people of their money, by striking hands ourselves, or becoming surety for others, when we have not to pay. If a man by the divine providence is disabled to pay his debts, he ought to be pitied and helped; but he that takes up money or goods himself, or is bound for another, when he knows that he has not wherewithal to pay, or that what he has is so settled that the creditors cannot come at it, does in effect pick his neighbour’s pocket, and though, in all cases, compassion is to be used, yet he may thank himself if the law have its course and his bed be taken from under him, which might be taken for a pledge to secure a debt, Exo 22:26, Exo 22:27. For, if a man appeared to be so poor that he had nothing else to give for security, he ought to be relieved, and it was honestly done to own it; but, for the recovery of a debt, it seems it might be taken by the summum jus – the strict operation of law. 3. We must not ruin our own estates and families. Every man ought to be just to himself and to his wife and children; those are not so who live above what they have, who by the mismanagement of their own affairs, or by encumbering themselves with debts of others, waste what they have and bring themselves to poverty. We may take joyfully the spoiling of our goods if it be for the testimony of a good conscience; but, if be for our own rashness and folly, we cannot but take it heavily.