The key to understanding this is in the second half of the sentence. "Squire Trelawney, Dr. Livesey, and the rest of these gentlemen having asked me to write down the whole particulars about Treasure Island, from the beginning to the end, keeping nothing back but the bearings of the island, and that only because there is still treasure not yet lifted, I take up my pen in the year of grace 17—, and go back to the time when my father kept the Admiral Benbow inn and the brown old seaman with the sabre cut first took up his lodging under our roof."
Obviously it's a very long sentence, and most people don't write this way any more. But we could edit it down a lot, and a shortened version might be:
"Gentlemen having asked me to write about Treasure Island, I take up my pen."
The idea is "because they asked me to write, I take up my pen."
Not many people write this way any more, but you do still find the phrase. Someone might say something like, "having accepted the invitation, I couldn't make other plans for the evening."
From a grammar point of view, the first part of the sentence modifies the second. If you want to know more about this construction, look up "participial phrases."