Learn what is known as the basic opening principles, and apply them to your game. Since you're a beginner, memorization of long opening lines is a wasted effort at this stage of your chess development, and will not help you in the long run.
In short, the basic opening principles can be described as working towards accomplishing three main goals.
- Fight for control over the central squares (e4,e5,d4,d5).
- Get your pieces out from their starting positions.
- Get your king to safety.
The reason for trying to fight for the center is that this will give you more space to use for your pieces.
The reason for trying to get your pieces out from their starting positions is that pieces that are just sitting on the sidelines of the board tend to be useless spectators.
Finally, the reason for trying to get your king to safety is of course because the king is the one piece that you need to protect at all costs.
So, how do you accomplish these goals successfully? In truth, there is no easy set of rules that is going to bring you success in every possible game, but there are some good and easy to follow guidelines, which I will go over below.
- Begin by pushing a central pawn forward. If you're white, either 1.e4 or 1.d4 are excellent moves to begin the game. If you're black, I'd recommend that you respond to 1.e4 with 1...e5, and to 1.d4 with 1...d5. Other moves are also fine, but I'd recommend these since they are easier to remember. With this first move, you fight for control of central squares, and you're opening up for one of your bishops to be developed.
- Bring out your knights to f3 and c3 (as white) or f6 and c6 (as black). This way your knights are developed from their starting positions, and they are also fighting for control over squares in the center.
- Now it's time to develop your bishops. If you can without losing them, bringing them out to the 4th or 5th ranks may be best, as they are often quite active there, looking down at the opponent's position. Developing the bishops to the 2nd and 3rd ranks are often a bit more solid options.
- At this stage, if everything has worked out as outlined above, you should be able to put your king to safety by castling. If you are unsure whether you want to play short or long castling, you may move your queen out of the way.
- Finally, it's time to connect your rooks by moving your queen out of the way, and after this it is often a good idea to place your rooks along open files, or behind a pawn you intend to push forward soon.
After this, you should have a playable middlegame position in most cases, which is what you want as a beginner. Finally, I'd like to try to explain why I've recommended you play the opening in this particular order most of the time.
Hopefully it is clear that the point of beginning by moving a central pawn forward is because we're trying to be efficient when trying to fulfill our opening goals. Note that I'm advocating that you focus on getting your pieces out rather than making a bunch of pawn moves in the opening. This is an important thing to remember: if you waste your time moving pawns in the opening with no clear objective, your opponent will finish their development first and will therefore be able to coordinate their pieces into launching an assault on your position before you can do the same to them. This is not good, trust me on that.
Secondly, the reason I'm advocating that you develop your knights before your bishops is because it can be difficult to know exactly where you most want your bishops at an early stage. In contrast, your knights will stand well on f3 and c3 (or f6 and c6 as black) in most cases. Thus, by waiting a bit before committing, it may become easier to decide where the bishops are best placed if you don't rush it. On the other hand, if you know where the bishops are headed, there is nothing inherently wrong with bringing one of them out before both knights are developed.
A third point I'd like to highlight is that I'm advocating that you wait with developing your queen until after you've developed your knights and bishops. This is because the queen is way more valuable, and therefore more vulnerable, than the minor pieces; if your queen develops early, and your opponent develops one of their minor pieces by attacking your queen, you will have to move the queen again, thus wasting time.
As a last point, I'd like to emphasize that these guidelines I've posted are not a recipe for success in every possible scenario. Remember that you're playing against an opponent that is not going to cooperate and let you execute your plans in peace. Sometimes they might force you to react to threats, so be alert and make sure that you don't drop pieces and/or pawns just so that you can follow the guidelines posted above.