The different spellings are due to the word's origins. "Gherkin" comes from the Dutch word "gurken," which itself comes from the Middle High German word "gurke." Over time, the spelling of the word has evolved in different languages.
However, gherkin is the most widely accepted and used spelling in English.