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.
I believe that the vinegar was to cause more pain. The bible saids: (Luc 23:36) "And the soldiers also mocked him, coming to him, and offering him vinegar"; they doesn't wanted to diminish his sufferings.
My personal experience without any food eaten and with a heatstroke at 11am in a hot and humid day, after drinking a glass of a excesively fermented palm wine (alcohol with acetic acid --vinegard--) is one of dizziness and stomach ache.