The German Order occupies the island 1398 to end piracy in the Baltic.
Queen Margrethe I of Denmark-Norway-Sweden tries to conquer the island 1403 but is repulsed by the knights.
1408 Margrethe once again tries to take the island this time by barter but the knights have found it to be a valuable possession and haven't forgotten the last forcible attempt and rejects the offer.
During the reign of Eric of Pomerania there's no time for the Danes to try retake Gotland; first there's prolonged war with the Holstein counts and then civil war within the Kalmar Union.
Following Eric's leaving the throne the Kalmar Union dissolve and Gotland and its knights are left to themselves.
The Swedes also tries conquering the island but the knights are able to hold it though at short intervals it is occupied by the Swedes.
When the German Order came under increasing Russian and Polish pressure during the early 16. century the Grand Master converted to protestantism secularing the lands to a Duchy though the castillan at Gotland decided against this and became part of the new order and due to his staunch sticking to catholicism managed to be recognized as the new grand master. As such he was able to draw upon resources from catholic Germany.
Balancing between Denmark-Norway, Sweden, Poland and Russia the grand master by usually allying to the Hanse managed to stay independent.
Come reformation in Scandinavia and floating in a hostile sea the grand master realized that it was time to change directions. Once more the German Order was secularised with the grand master once again becoming a duke but this time the burghers of Visby decided against becoming part of either Sweden or Denmark-Norway and deposed the duke instating a republic.
Being rich and able to pay off the most greedy of their neigbouring kings or raise an army and a navy when needed the republic of Gotland managed to make its way through the next century.
With none of its neighbours willing the let one of the others take control of Gotland it though at times it would be occupied by Swedish or Danish troops though the burghers were always able to buy them off.
The arrival in the Baltic during the 18. century of the Royal Navy made for the British to decide it to be a perfect point of resupply due to its central position. As with the earlier Danish deprivation of both banks of the Oeresound all states around the Baltic were diplomatically told to keep their hands off.
It proved much cheaper than making it a possession or colony.
As an independent republic Gotland made its way into the 19. and then 20. century at times threatened by a big neighbour but making it through in the end and taking its place among the Northern Nations - Denmark, Norway, Sweden, Finland, Iceland and Gotland.