It’s common for role-playing rules to include tables for generating complex results, similar to the image to the right from the first edition Dungeon Master’s Guide for generating dungeon maps. The user is meant to roll a twenty-sided dice and find a matching row from the first column. A roll of 4 matches the range of 3-5, indicates a door in the random dungeon and directs the user to Table II.
Automating the results with code provides two advantages over manually rolling. In the moment, at the table, it can be quite dramatic to click once and see a result. The other advantage is being able to rapidly re-roll and pick suitable results, such as when working on a new adventure and riffing on random results.