There is a nice introduction to script and already another answer explaining what these specific commands do, but I will try to explain what these scripts actually do.
They implement a very standard bitcoin transaction called pay-to-pubkey-hash transaction.
The idea is roughly the following. Let's call this transaction
A. To spend the output of transaction
A, another transaction will be created and broadcasted, let's call it
B. In order to verify the validity of transaction
B, one should:
- combine the input script of
B with the output script of
- execute the combined script and verify that it returns
In this type of transactions, transaction
B should provide an input script that puts two elements to the stack: the signature
sig of the transaction and a corresponding public key
pubKey. Note how the input script of transaction
A is also doing exactly that.
Then the output script of transaction
A will do the following (in your question you actually provide two output scripts merged together, because there are two outputs, I will focus on the first one):
pubKey on the stack;
- Hash one
pubKey from the stack and verify that it is equal to
sig and the remaining
pubKey from the stack and verify the validity of the signature.