I think it's luck and determination. However, I believe that there are systems applied by the game developers to spread the good weapons. So by being 'smart', we can learn how things usually work, and maybe we can raise our chance of getting good loot.
I will compare it with gambling on a slot machine (not gambling by blackjack or poker). Look at this analogy: There is one out of tens of thousands, or hundred of thousands, or millions, that one slot machine it going to hit a winning number/combination. But after a machine produces a winning number, the chances - that the same machine is going to hit another winning number any time soon - are practically going down very low, if not close to zero. So this is different than gambling a la blackjack or poker, or playing a lottery. Blackjack and poker can be broken down to a higher percentage of math and some luck. Playing a lottery is practically all about luck. So looting is not all about math (probability, than we can learn to raise our chances), and it's not all about luck either.
I believe that good weapons are spreaded in all servers. The best weapons are probably assigned with a certain number, for instance, 1 legendary weapon on each server for each week, and 10 famed weapons (of any assortment) on each server for each week (until somebody finds it). Or whatever frequency the game developers decide (I was just trying to give an illustration). So if a pirate already 'wins' a legendary weapon on one server, chances are, there will be almost no body would win another legendary weapon the next day, on that same server. So it's smarter to not to look for a legendary weapon on the server that we know somebody just won it the previous day. It's a probability theory. However, we cannot raise our probability without luck.
Who will be lucky enough to get that legendary weapon on certain server? It could be "anybody". But if we are persistent and determined to spend a lot of time to look for a legendary weapon, the more time we spend on looting, I think, the more we raise our chances to get a legendary one. Does that mean that we will, by spending more time looting? No. Because by pure luck, somebody could just chime in and loot with us, and it's almost time for the server to give away a legendary weapon. So we - who have been spending much time looting - and another person - who just came in - could have the same chance of getting that legendary weapon on that server. I'd strongly assume, that if somebody just got a legendary weapon on one server, there is no use looking for another legendary on that same server, on the same day.
Still some ppl are luckier than others. So I'd suggest:
1. Be diligent on looting; spend a lot of time to raise your chances.
2. Be smart; don't follow other lucky pirate to one server just because we think that one server is luckier than others, or that we could get another legendary weapon on the server that just dropped a legendary one not too long ago. And especially not because of one lucky pirate would bring you the luck as if 'luck is contagious'.
3. Pray that you have the luck. This it totally beyond our control. While #1 and #2 can be exercised, #3 is something that we cannot do anything about to make our chances bigger to get better loot.