I wonder if there were any attempts to come up with better algorithm that will allow you to mine BTC faster than others? I mean, if I understood correctly, all you have to do is run the hash function with the desired outcome, in this case, with the leading 17-19 zeros. So, is there better algorithms or bruteforcing is the only way?
Bitcoin is designed to work this way.
The whole security and the foundation of its blockchain is the Proof of Work, and the "work" is this "bruteforce" of hashing.
What you are suggesting, a "better algorithm" to create the desired hash without bruteforcing, is basically to break out SHA 256, reversing a hash function. You would be basically destroying cryptography.
The implications of your suggestion would be terrible for computer security and cryptography. You would be able to even reverse public keys to private keys:
https://abeldantas.com/mastering-bitcoin/
I created a brief explanation of how Proof of Work works long ago, but it is still valid (
https://bitcointalk.org/index.php?topic=3317586.0)
Basically, you need computer power to generate as much hashes as possible, until you find a
nonce (a number) that once hashed is low enough to "solve" the Proof of Work algorithm and create a new block.
As hash is a only way function (you cannot
unhash anything), the only way to do so is by bruteforcing nonces (hashing random numbers, millions per second) and checking their hash.
You are suggesting that someone could build an algorithm that you would reverse the hash function: you choose the hash, then it would return you the nonce.
There is a nice demo of how Proof of Work works here:
https://andersbrownworth.com/blockchain/blockchain