Transfer moves money from contract's account to the beneficiary one, while balance is a lookup function that takes one arbitrary address as input and gives back its balance.
msg.value
is the amount of Ether send along with the message.
If you want to send all money of the contract you have to write something like that:
function f(address payable beneficiary) public {
beneficiary.transfer(address(this).balance);
}
If you write something like that:
function f(address payable beneficiary) payable public {
beneficiary.transfer(msg.value);
}
Whenever, the msg.sender sends msg.value
Wei to the contract. The latter transfers the money to the beneficiary. In this case the smart contract is a broker that gives the received money to the beneficiary one.