It was some sort of potion designed to dull the senses and lessen the suffering of those being executed.
Biblehub contains several commentaries on this verse. One from Ellicott’s commentary reads in part:
It was clearly something at once nauseous and narcotic, given by the merciful to dull the pain of execution, and mixed with the sour wine of the country and with myrrh to make it drinkable. It may have been hemlock, or even poppy-juice, but there are no materials for deciding. It is probable that the offer came from the more pitiful of the women mentioned by St. Luke (Luke 23:27) as following our Lord and lamenting. Such acts were among the received “works of mercy” of the time and place. The “tasting” implied a recognition of the kindly purpose of the act, but a recognition only. In the refusal to do more than taste we trace the resolute purpose to drink the cup which His Father had given Him to the last drop, and not to dull either the sense of suffering nor the clearness of His communion with His Father with the slumberous potion. The same draught was, we may believe, offered to the two criminals who were crucified with Him.