Vaxholm Castle was originally constructed by Gustav Vasa in 1544 to defend Stockholm against shipborne attacks from the east, but most of the current structure dates from 1833-1863. The stretch of water below the building was formerly the main sea route to Stockholm. Thus, the fortress was strategically situated to defend the city from naval attacks. The castle was attacked by the Danes in 1612 and the Russian navy in 1719. Since the mid 19th century, its military importance has ceased. Today, it is home to the Swedish National Museum of Coastal Defence.
In 1970, it was used as a movie location for the pirate stronghold in Pippi Longstocking in Taka Tuka land. A scenic view of the castle may be seen from the car ferry which plies the short distance between Vaxholm and Rindö.
References:
Wikipedia