Miners don't just find hashcodes.
Miners solve blocks. They take unconfirmed tx, validated them, pack them into a block and then find a hash which "solves"* the block. As part of the block creation they are allowed to add a special coinbase tx which mints a certain number of new coins (it was 50 and now is 25) called the block subsidy along with any tx fees included in the tx which are part of the block to an address the miner/pool controls. This serves two purposes, first it provides a financial incentive to keep the network secure and second it slowly increases the supply of coins. Once a miner solves a block it broadcasts the block to other nodes who validate it and add it to the blockchain. Miners then start working on the next block in the chain including more unconfirmed transactions and looking for a solution to that block. The process never ends. Miners ARE transactions validators. Not only do they validate that transactions are valid the blockchain they produce provides a record which prevents someone from spending the same coins twice. The network is designed so that no matter how many miners there are one block will be found roughly once every ten minutes. M ining is intentionally difficult to make it very very expensive for someone to try and rewrite history. Without miners the coins would have no value. People could spend the same coin over and over and over, not just twice (double spend) but hundreds or thousands or millions of times. If you could spend the same dollar bill a million times you likely wouldn't need any more money.
If everyone could do that then a dollar would be worthless. Without miners there are no blocks, without blocks there is no blockchain, without the blockchain the coins have no value.
TL/DR version:
Miners secure the network. Miners validate transactions and create the permanent record (the blockchain) which prevent double spends.
* By "solve" the miner must randomly try hashes to find one which is smaller than the target which is based on current difficulty. difficulty adjusts every 2016 blocks in order to make the process of solving a block harder or easier and thus keep the generation rate roughly stable.