There is a special function called a cryptographic hash. Basically it takes anything as input and produces a fixed-length output. For all intents and purposes here, you can basically treat the output as being random. Meaning you can’t predict what the output is going to be for any given input without simply trying.
For miners, the input is the block they want to add to the block chain, plus a magic number they get to come up with. They then combine the two and perform the cryptographic hash. What they’re looking for is for a output of the hash that has certain properties. For example, the hash (being a number) has 32 trailing zeros.