The life of a naval officer or professional sailor is spent mostly on a ship. Shore leave refers to permission granted to crew to spend time on leave ashore on land. Shore leave also refers to the time itself that is spent ashore during leave.
In days gone by, hundreds of years ago, ships were run exclusively with males, and contact with loved ones back at home only came in the form of letters. With the ensuing loneliness and the sudden absence of the tight discipline required onboard the ship, shore leave for sailors often meant boozing and wenching excessively for the short time they had on land before the ship was due to leave port again. Drunken brawls would be common. It was not unusual for ship captains to have to hire new crew members to replace ones lost after shore leave due to desertion, incapacitation, or landing in jail.
Shore leave these days no longer has quite the same reputation as days gone by. This is possibly due to it being much easier to stay in contact with loved ones with phones and social media, journeys by ship no longer taking as long, and also ships are no longer run male only as standard.