Below is a simplified explanation of how the automatic draw algorithm works, using the pulling-names-from-a-hat method but with a few extra steps.
The draw is as random as possible, given the one parameter that it will create a draw with the minumum number of venue clashes possible. (Including preventing home draws where the venue is closed on the fixture date. We have the Alternate Venue for teams and Home Venue for players to compensate for this.)
There is also a live example using the same icons as the diagram that calls the exact same function that does the tournament draws. Click the re-draw button a few times and you'll see that there are always the minimum number of venue clashes possible (2), and the grey "closed venue" icons are always drawn away. Despite this, it's clear that the actual pairings are still very "random".
The randomisation is done by the PHP shuffle() function. While you wouldn't use this function to generate cryptographically secure random keys for authentication purposes, it is "as random as it gets" for the likes of tournament draws.
1. Each venue has a "hat" containing the teams/players that play from there.
2. One team/player is pulled at random from each hat. These will make up the at-home draws. This ensures as many venues as possible are utilised for the tournament. Venues that are closed on the fixture date aren't used yet.
3. We now have 6 teams/players drawn at home, so we need 2 more to make it up to 8. Two hats that still contain teams/players are used at random.
4. The at-home teams/players go into one hat, and the rest go into another.
5. Pairs are pulled from the hats at random to make up the draw.