Welcome, Moxuan !
Neither in philosophy nor in ordinary moral experience is the concept of luck unequivocal. So the first thing we have to do is to fix the concept, to decide what construction - definition or analysis - to apply to it.
Three approaches to the definition or analysis of luck are relevant. They centre on control, probability, and modality.
Control
Two quotations will help to set out this approach:
An event is lucky for a given agent, S, if and only [if] the occurrence of such
an event is beyond—or at least significantly beyond—S's control. (Lackey, J. (2008). 'What luck is not', Australasian Journal of Philosophy, 86(2), 255-67: 256.)
An event or state of affairs occurring in the actual world... is non-chancy
lucky for an agent if (i) that event or state of affairs is significant for the agent; (ii) the agent lacks direct control over that event or state of affairs; (iii)
events or states of affairs of that kind vary across the relevant reference group,
and (iv) in a large enough proportion of cases that event or state of affairs fails
to occur or be instantiated in the reference group in the way in which it
occurred or was instantiated in the actual case. (Levy, N. (2011). Hard luck: How luck undermines free will and moral responsibility. Oxford: Oxford
University Press: 36.)
This could be clearer - and that's putting it mildly - but the vital dimension is the extent to which the event - usually the cconsequences of an action - is beyond the agent's control.
Probability
The main philosophical defender of the probability theory of luck is Nicholas
Rescher. In Rescher (1995) he argues that only improbable events can be lucky or
unlucky, and that their degree of luck is a function of the event's improbability and
its importance ... Thus the occurrence of
a mildly improbable event that is very important might be just as lucky as a very
improbable event that is only somewhat important. Very important, very unlikely
events are the luckiest of all. No luck whatsoever attaches to events that are wholly
unimportant or are certain to occur. (Steven D. Hales, 'A problem for moral luck', Philosophical Studies: An International Journal for Philosophy in the Analytic
Tradition, Vol. 172, No. 9 (September 2015), pp. 2385-2403: 2387; Rescher. N. (1995). Luck: The brilliant randomness of everyday life, New York: Farrar Straus Giroux: 211.)
Modality
The modal theory of luck is common among epistemologists. According to this
view, an event is lucky only if it could very easily have not occurred. The most
prominent defender of the modality theory is Duncan Pritchard, who writes, "if an
event is lucky, then it is an event that occurs in the actual world but which does not
occur in a wide class of the nearest possible worlds where the relevant initial
conditions for that event are the same as in the actual world" (Pritchard 2005 p. 128,
see also Pritchard 2014). Epistemologists like the modality approach because then
epistemic luck involves "a true belief that could very easily have been false"
(Pritchard 2012 p. 272) and due to epistemic luck, "the fact that you could very easily have been deceived is a ground to deny you knowledge, even if in fact you
were not deceived" (Pritchard 2012, p. 275). These ideas pave the way for requiring
a popular safety condition on knowledge, which states that S knows that p only if
S's true belief that p could not have easily been false (although see Goldberg 2015
for a recent criticism). Modally robust events, on the other hand, are not due to luck.
A true belief that is false only in distant possible worlds is (or is at least a worthy
candidate for) knowledge. It cannot be a matter of luck that a necessary truth is true,
or that an inevitable event occurs. A proposition that remains stably true as one
moves further and further away from the actual world is less and less attributable to
luck. (Hales: 2387-8; Pritchard, D. (2005), Epistemic luck. Oxford: Oxford University Press; Pritchard, D. (2012), 'Anti-luck virtue epistemology', The Journal of Philosophy, 709(3), 247-279; Pritchard, D. (2014), 'The modal account of luck', Metaphilosophy, 45(4-5) : 594-619.)
Down to earth with examples
Consider how the three different theories on offer explain winning the lottery, a
paradigm case of (good) luck. Under the control theory you are lucky to win
because winning was beyond or significantly beyond your control. Winning was
significant for you, you lacked direct control over that event, and there is
tremendous variance across lottery players (most lose, despite doing what's in their
power to win). You're lucky to win the lottery on the probability view because it
was of great importance to you that you win and it was so vastly unlikely that you
would do so. For the modal view you are lucky to win because winning mattered to
you but your win failed to occur in close possible worlds; had you picked one
different number, or had a single ball in the lottery hopper rotated an extra 20°, or a
myriad of other small changes in the world occurred, then you would have lost.
While the different theories offer distinct explanations of why winning the lottery is
lucky, they are all in agreement that it is in fact lucky. One might suspect that they
are notational variants on each other, or at least extensionally equivalent. However,
they are not. (Hales: 2388.)
Moral luck and moral responsibility
The control theory seems to come closest to how luck connects with moral responsibility. Indeed, I can't see how the probability and modality approaches affect the agent's moral responsibility, however significant (or otherwise) they might be in other ways.
But we immediately encounter the problem posed by the question. If (say) the consequences of my action are beyond my control, how can I be morally answerable for them ? How can moral responsibility properly be attributed to me?
There isn't just one road out of this problem but we can appeal to what I'll call the Kantian insight. Namely that the very fact that we do not have control over the consequences of our actions is a good, in fact decisive, reason to remove consequences from the conditions for moral responsibility.
One of Kant's key ideas is that whatever the limitations of our control over what our action effects or accomplishes - i.e., its consequences - we have a capacity to act with a certain intentionality that Kant calls 'the good will' (I. Kant, Groundwork of the Metaphysics of Morals, 1785, section 1.) Very briefly and crudely this may be expressed as an intention always to act on a principle on which it is logically possible for all other agents to act conjointly. A non-Kantian example might be: I will always act so as to put myself in the first place in any queue I join. It is logically impossible for everyone to act on this principle. How could everyone be in first place in a queue?
Kantian scholars on PSE can finesse my account but I have cited Kant only to show how we can be morally responsible even in the absence of control. We can be and at least to an extent are responsible for our intentions whatever contingencies of luck our actions and their consequences encounter.