The opening is a race to get all your pieces out. If you do this job better than your opponent, you will have more pieces to attack with, and you could checkmate your opponent.
How much is it worth to get ahead in development?
A gambit is an opening idea where one side says: I will give you a pawn if you let me have a free move!
So this is the Danish Gambit:
[Event "Danish Gambit"] [Site "Gambits"] [Date "2019"] [Round "1"] [White "NN"] [Black "NN"] [Result "*"] 1. e4 e5 2. d4 exd4 3. c3 dxc3 4. Bc4 cxb2 5. Bxb2 *
White has given up two pawns but has two strong Bishops with open lines pointing to the Black kings'-side
You don't have to take gambit pawns, and, if you do take them, you can let go of them to get on with your own development. So in this position, Black often plays 5...d5!, handing back a pawn but opening a line for the Bc8.
This is a famous gambit game, using Evans' Gambit:
[Event "Friendly"]
[Site "New York, NY USA"]
[Date "1963.03.??"]
[EventDate "?"]
[Round "?"]
[Result "1-0"]
[White "Robert James Fischer"]
[Black "Reuben Fine"]
[ECO "C52"]
[WhiteElo "?"]
[BlackElo "?"]
[PlyCount "33"]
1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. b4!?
{White offers a pawn}
4...Bxb4 5. c3 Ba5 6. d4
{That was White's idea: give up a pawn to get a big centre}
6...exd4
{Black doesn't want White to have it all their own way}
7. O-O dxc3?!
{Black grabs another pawn, just to see if he can get away with it. "They're like peanuts, you know" -- Stephan Gerzadowicz}
8. Qb3 Qe7 9. Nxc3 Nf6
{A good moment to take stock. If Black is left alone, he will get developed and safely castled, and enjoy making use of the extra pawns. So White must not leave him alone!}
10. Nd5! Nxd5 11. exd5 Ne5
{White has found a way to keep poking at Black, which swaps off some of White's developed pieces, but Black's few developed pieces also vanish, leaving the poor Queen to do everything.}
12. Nxe5 Qxe5 13. Bb2
{More time gained.}
13...Qg5
{Holding onto the g-pawn. White pokes again...}
14. h4! Qxh4 15. Bxg7 Rg8
{Now Black's King is trapped in the middle of the board.}
16. Rfe1+
16...Kd8
{Black's King now doesn't have any moves at all! So any check by White will be checkmate. Bf6+ looks good, but the black Queen is guarding f6. Can White remove the guard?}
17. Qg3! 1-0