The difficulty, the target and the hash value are all integer numbers. They can all be compared numerically in much the same way we can compare three and seven.
Since these are large numbers it is more convenient to use a more compact representation of the number when displaying the number. Just as base-16 (hexadecimal) is a more compact way of writing a number than base-10 (decimal). So the network target is transmitted in a compact representation known in the Bitcoin context as the "bits" representation. But the choice of representation doesn't affect the fact that these are just integers and can be compared to other integers in the usual ways that large integers are compared. I think of the "bits" representation as being a little like writing down a number rounded to the nearest thousand or a little like writing down a number as three significant digits and an order of magnitude. You lose some precision but the result is still useful.
The difficulty is a kind of inverse of the target. The larger the difficulty, the smaller the target. The target is a number that is adjusted every 2016 blocks using relatively simple arithmetic. It is not the result of hashing.
The hash is produced by an algorithm that I wouldn't characterise as simple arithmetic but it is still just an integer value. One whose value cannot be predicted more easily than by performing the hashing operation and whose results do not follow a predictable pattern and which are uniformly spread through the range of possible results. Those characteristics make it useful.
So to take your example
how does an SHA256 hash, i.e: 58a57cbaefb39229b8bb7f7f5ba4dae105cd4a75aa1cd72873ee74fdb323a201, have a value higher or lower than 27Trillion
- The number three is the number 3. They are the same number written down in two different ways.
The number 58a57cbaefb39229b8bb7f7f5ba4dae105cd4a75aa1cd72873ee74fdb323a201
is the number 40095921297356466623732964073191944615316514476168542186617738139837166494209. They are the same number written down in two different ways.
The number 27 Trillion is the number 27000000000000. They are the same number written down in two different ways.
The first step in comparing two numbers which are represented two different ways is to convert them both into the same representation. We choose any representation that will make a subsequent comparison easier for us.
We can immediately see that 40095921297356466623732964073191944615316514476168542186617738139837166494209 is a larger number than 27000000000000.
We need to be careful to compare the hash with the target and not with the difficulty.