God made that rule. He is sovereign over everything and everyone. He is holy and will not tolerate sin. All sin against God must be paid for. All mankind since Adam has been born sinful due to Adam's sin . The price that must be paid is death. Before Jesus, God the Son, came God allowed His chosen people to pay for their sins by sacrifice of their most prized livestock.
Then Jesus came as a baby, born of a virgin so that His life would be free of the inherited sin of everyone else. He lived a sinless life and was tempted as we are because He was fully man. He willingly died as the ultimate sacrifice, the Holy Lamb of God, to pay for the sins of all people who will confess their sins and be forgiven of them.
Salvation is a gift from God. No amount of good works or money or anything else will get you there. You must believe that Jesus is the Son of God and that He is happy to save from eternal death in he'll. You must confess that He is God and you are a sinner in need of salvation, ask Him for forgiveness and you will be forgiven.