I can understand that the general Nim game page as given in a comment can be overwhelming.
For 2 stacks, the answer can be stated simply
A player 'on the move' will lose (on optimal play of opponent), if the number of coins in the stacks are equal.
If the number of coins on the stacks is both $0$, that is obvious, they cannot make a move.
Otherwise, they make a move that changes one stack to a stack with a smaller number of coins. Then their opponent can 'mirror' that move: They take the same number of coins from the other stack.
That again creates a situation where the first player is again 'on the move' and again the number of coins in the stack is equal (smaller than before). Since this can't go on indefinately, the first player will finally loose at some time later.
Now if you are the player to start the game and the number of coins in the stacks is equal, you will lose, as explained above. If they are not equal, you can make them equal: Take from the stack with more coins just as many to get the same number remaining as is in the other stack. Now your opponent is on the move, and because the number of coins in both stacks is equal, your opponent will lose, so you win!