The first transaction of each block is special according to the Bitcoin Protocol, and people give it a special name: generation transaction (because it can generate new bitcoins) or coinbase transaction (because it's the only transaction to contain a field called the "coinbase" [the company Coinbase is named after this field, but is otherwise unrelated]).
Generation transations have the following rules (among others not relevant to your question):
One, and exactly one, generation transaction must be present in every block. (If you've ever heard of "empty blocks", that just means a block with nothing besides the generation transaction.)
They can only have one input.
That input "spends" an output (outpoint) of all zeroes. This doesn't correspond to any actual transaction output.
That all-zero outpoint is considered to contain the newly-generated bitcoins (subsidy) for this block as well as the transaction fees paid in this block (fees), which are collectively known as the block reward.
The special input has a field called the coinbase field where the signature script (scriptSig) would go in a regular transaction. Anything put in this field is validated like in a normal transaction, but in the original Bitcoin protocol, miners were not required to put anything in this field at all---they didn't need to provide a signature since the only person who could've created this transaction as the first in the block was the miner themselves. Since them, BIP34 and BIP141 have changed the rules somewhat, but not in a way relevant to your question. Also not particularly relevant, the coinbase field is limited to 100 bytes in length.
Actual validation works like this:
When a node receives a new block, it starts by looking at all of the transactions besides the generation transaction. It calculates how much transaction fee they all pay.
Then the node calculates the amount of new bitcoins (subsidy) the miner is eligible to claim, for example 50 BTC for the first 210,000 blocks or 12.5 BTC as of this writing (blocks 420,000-629,999).
The node adds these two numbers together. This is the maximum amount of block reward the miner can claim.
Now the node looks at the generation transaction, makes sure it follows all of the other rules, and validates that its outputs spend a total of less than or equal to the block reward computed above.
Of interesting historical note, the generation transactions in over 1,000 blocks did not claim all the block reward they were eligible to claim. This seems to have mostly occurred early on. What happened to those bitcoins? They can't be claimed by the miners of those blocks after the fact and nobody else can claim them, so they're permanently lost.