Chests can be earned, in increasing order of probability, by:
 Completing quests (hard limit of 11 Basic Chests and 13 Golden Chests)
 Bought with tickets (premium currency, so very limited)
 Traded in a trading post
 From Caves
 From scientist excavations
 And above all, found by Miners
You can also get Gold Chests and Ethereal/Black Chests through the Chest Compressor
Ethereal/Black chests were added in v0.40, on Oct 24th 2022
Found chests[]
Chests are found by miners. The deeper you go the more miners you have & the more chances of a chest being found. Chests even spawn while at full capacity. The Metal Detector will help to locate and collect the spawned chests.
Gold chests are the second rarest and have a 1/158 base drop chance. They contain the best rewards but it could take a long time to get what you want from them. Technically, Black/Ethereal overwrite these (if the random roll passes for both Golden Chest and Ethereal Chest, Ethereal is given), so the probabilites drop from 1/158 (0,633%) to 4/790 (0.51%). However, if Keys of Gold are being used, this effect becomes weaker.
Ethereal chests are the rarest and have a 1/790 base drop chance (20% that of a Gold Chest) but this can be increased through relics. (for a cheat sheet of % spawn chance for Key of Void (KoV) and Key of Gold (KoG) click here)
Chest spawning intricacies (up to date 0.44)[]
KoG = Key of Gold
KoV = Key of the Void
There are 2 sets of relics which boost the chance of getting a gold or Ethereal chest, the 2 relics are Key of Gold
and Key of the Void
boosting gold chest spawns and ethereal spawns respectively.
They boost the spawn chance of a chest type by a set percentage (with a cap of 80% for KoG and 85% for KoV)
Now to dive into the code that controls which type of chest spawns[]
First, the relic effects get collected, which is from a chain of functions which result in this function (new line) where x = % as int (so 40% = 40).
(((x)/100)*1)+1)
which can simplify into
1(x/100)
This is what are chance multiplier is (though this doesn't account for the relic cap, which is 80 for KoG and 85 for KoV).
then into the type code:
rollForSpecialChest() { let goldenChestChance = randRoundToInteger(1580 * STAT.goldChestSpawnFrequencyMultiplier()); //1 in 158 let canSpawnGoldenChest = chestSpawnRoller.rand(0, goldenChestChance) <= 10;
let blackChestChance = randRoundToInteger(7900 * STAT.etherealChestSpawnFrequencyMultiplier()); //1 in 158 let canSpawnBlackChest = chestSpawnRoller.rand(0, blackChestChance) <= 10;
if(canSpawnBlackChest) { return ChestType.black; } else if(canSpawnGoldenChest) { return ChestType.gold; } else { return ChestType.basic; } }
goldenChestChance can be simplified to round(158015.8x) x = KoG%
blackChestChance can be simplified to (790079x) x = KoV
Then, this chance it used as the maximum value in the RNG function and then checks if the value is less than or equal to 10.
Thankfully we can just divide the chest chance by 10 to get it <= 1 which lets us just use Chest Chance as the denominator.
So you have 30% KoV, then we have 790079*30 = 5530, 5530/10 = 553, 1/553 chance for ethereal chest.
Chest cap[]
Spawned chests have a cap: There can be no more than 1/10 of your depth (so, if depth 1000, you can have a maximum of 100 chests waiting). Super Miners who spawn chests can bypass this up to 2x the cap.
Timers[]
 Historical note
This was removed on v0.40. On previous versions, chests appearing in mineshafts used to have timers. The base advice from MineBot (on Discord chat) is "Chests have timers so it's best to check every 510 minutes for them before they expire as you wouldn't want to miss a gold one". However, code analysis shows that every chest has a timer (defined on chest spawn) from 40 to 90 minutes, both for basic and golden chests. The advice on checking them out frequently is still valid if you want to maximize # of chests spawned.
Chests collected by the Metal Detector do not have a timer, and thus cannot expire.
Spawn Timing[]
Every 30 seconds (the "tick"), the game will generate chests for every mineshaft in the mine (so, more probable the more depth achieved). If a floor already has a chest, it decreases its TTL (time to live). The base TTL is between 40 and 90 mins. So, the more unclaimed chests, the less probability of new chests spawning.
Then it applies a formula dependent on the max floor reached, so when on upper floors you have more probability of spawning a chest (but as you get deeper, you have more rolls, so in net, you get more chests per minute). The formula compares a fixed number (21) against that number, modified by a random roll. The base probability is a maximum of 0.7%, per floor, per tick when on the upper floors, to a minimum of 0.3% at the lowest floors. However, the "fixed" number 21 is based on the number of workers hired on the Earth. <Number of Workers>*2+1, which is relevant for the first part of the game. So if you have 5 workers, the probability on floor 50 will be 11/2850 = ~0.38% per tick. Thus, the rate of chests generation, besides having a random component, depends on your depth progress.
Building Materials limit calculation[]
Whenever there is a change to get a BM from a chest, the game first calculates how many BM you need for all current (not future!) unlocked upgrades. If you have enough BM for all of them, your BM rate will be reduced to 20% of the base rate (or to be more precise, the options where you can get BM are subject to a 20% random roll, if this roll fails you get the "next option"). This is both for Basic and Golden chests. While this condition should be usually rare, it's good to have it in mind if you're trying to accumulate BM for any reason (the associated quest for 1000BM, for example). Otherwise, it seems best to spend your BM regularly on upgrades so as to not reach this limit.
Reward generation method[]
This game does not use a straight "loot table" where you roll for a reward with a fixed probability. Instead, the system applies a combination of loot table with checks and conditions. The conditions are:
 For Gold Chests: your depth (for blueprints, extra km and scientists), your weapons (to unlock the two specials), # of active scientists, # of BM as previously explained, if your Oil Pump is full, and even your Metal Detector level.
 For Basic chests: # of current active buffs, # of BM, # of active scientists, depth (for scientists and oil), playtime (rewards change at 3h and 6h playtime), your weapons, and if your Oil Pump is full
 For both: Your Oil Pump level will determine how much oil you get (4h from golden chest, 1h from Basic chest), and your depth will determine how much money and minerals you get.
Basic chests[]
Rewards amount regarding money and minerals depend on the maximum depth you have reached
Applicable relics[]
 The Key of Luck relic increases the spawn frequency of chests by 5% (base) and up to 10% (divine). This stacks additively with a theoretical maximum (soft cap) of +150%.
 The base timelapse is between 3 and 10 minutes. Duration can be increased by 10% (base) to 15% (divine) Book of Time relic. This stacks additively, up to a hard cap of 100%.
 The amount of money can be increased by 10% (base) to 20% (divine) with the Nugget of Attraction relic. This stacks additively with a theoretical maximum (soft cap) of +300%.
 The higher your oil pump level is the more oil you get from chests (you get 1 hour of oil).
 The chance to find Building Materials can be increased with the Book of Ingenuity, by 6% (base) to 16% (divine). This stacks additively, with a theoretical maximum (soft cap) of +240%.
Loot Table[]
Ref  Reward  Chance  notes 

1  Scientist 
If depth >=50:


2  1 Building Material  Base rate 8%, reduced to 1.6% if you don't need BM for current upgrades. 

3  Buff 


4  Money  40%  Multiplier is 6 to 11 if depth>50 and over 3 hours of playtime, otherwise it's 3 to 6 
5  Timelapse  40%  If depth>40 and over 3h of playtime, it's 3 to 10 min. Otherwise it's 36 min. 
6  Minerals  10%  .12 hours (7.2 min) of production. If over 6h of playtime, mineral rewards are tripled. 
7  1 hour of Oil  7%  Only if depth>=303 and Oil Pump not full. Otherwise, fall through the next one. 
8  Weapon 

Only if depth>303 and if you still have one of the 8 normal weapons to unlock. Otherwise, fall through the next one. 
9  Timelapse 

Between 3 and 10 minutes, no matter playtime. 
 Technical Note
You will see that base rates may sum higher than 100%. That's because, as explained above, the game doesn't use a static loot table. Some options "fall through" to the lower ones. E.g. if the random roller lands on ref 7, but conditions are not met, then it goes on to try option 8, and if all else fails, option 9. Also, the rolls for scientists, building materials and buffs are made, in that order, strictly before the random roll for refs 4 to 9, so technically those base rates should be adjusted. As shown, those rates are conditional on refs. 1 to 3 having failed. But since refs 1 to 3 depend on your current game state, and moreso, scientist and buffs' probabilities are reasonably low, the table may stand. Adjusted by BM, both money and "standard" timelapse should be lowered to 37%, and for the rest, the effect is minor.
Gold Chests[]
Gold chests are golden colored and give better rewards. They have a base 1/158 chance of spawning, whenever a basic chest may spawn, instead of the basic chest. See below for the Key of Gold (KoG) mechanism.
Gold Chests are also rewards from quests, can be bought with tickets and can be received from scientists' excavations, from the trading post and from Caves.
Applicable relics[]
 Timelapse, money: Same as basic chests
 The Key of Gold relic (often referred as KoG) increases the spawn rate of golden chests by 5% (base) to 8% (divine). This stacks additively, but it's mostly useful at the extreme levels. The formula is (1/158*(100%<rate>), so it becomes much more powerful with increasing levels. E.g. at 20% (5 base KoG) the rate is just 127 (+25% improvement), at 40% (5 divine KoG or 8 common ones) the rate is 1/95 (+66% improvement), at 60% the rate is 1/63 (+250%) but at 80% (hard cap for this relic) is 1/31 (+500% improvement).
 The Key of Luck (KoL), though it "only" affects the basic chests, also affects the Gold Chests, because if you increase the spawn rate of the first ones, some of them will become Chests of Gold.
 The Chest Compressor will convert a number of Basic Chests into a single Gold Chest.
Loot Table[]
If you have at least one piece of the Tier 13 upgrades of the Drill (that is, at least on 225km, you need to buy it from the Broken robot), but no higher, the Gold Chest behaves differently, giving only the next blueprints. For this loot table, we'll asume you're either below or above that tier.
Base money amount is 1 minute of your mineral production (valueOfMineralsPerSecond()), multiplied by a random money multiplier. For Golden Chests, that money multiplier will be between 130*DepthMult and 530*DepthMult. DepthMult is 1 until Depth 1000km, and after this it grows by 1/1000 per km.
ref  chance  reward 

1  38%  money (straight, no conditions) 
2  32%  roll for Blueprints. If it fails, money (same as before) 
3  15%  Minerals 
4  3.5% 

5  3%  Give 20 Building Materials, unless it fails for the limit explained above, then it's money. 
6  3% 

7  0.5%  50 Building Materials, unless it fails for the limit, then 6h timelapse 
8  2.5%  
9  2.5% 

 Technical note, possible bugs
Unless I'm mistaken (Scarbrow speaking), reference #9 is bugged and should fail (giving nothing) if you already have Time Travel Weapon. As for #4, if I understand correctly you would never get the Rare Scientist (if you are under 899km, you should always get the extra km)
Ethereal chests[]
Also called "Black Chests" ingame. They can contain Super Miners or Super Miner Souls (materials used to upgrade them or buy new slots for more of them). You can get them through the Chest Compressor by compressing a certain amount of Gold Chests, or through regular chest spawn, at 1/790 rate (20% the rate of the Gold Chests). You can also spend 30 tickets to buy one, but this option isn't really recommended.
Your first Ethereal Chest will always give you a Common quality Super Miner.
There are currently no relics affecting the contents of Ethereal Chests, but the Key of the Void relic does increase the rate at which they can spawn (see above for this information).
Loot Table[]
 Main article: Super Miners
ref  chance  reward 

1  40%  Super Miner Souls, random amount between 35 and 50 
2  35%  Common Super Miner 
3  16.5%  Uncommon Super Miner 
4  7.5%  Rare Super Miner 
5  1%  Legendary Super Miner 