system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How long does uncooked rice (like the one milled and just packaged in bags) actually last?

I'm from an Asian country that loves rice, but now that I think about, I'm not actually quite clear what gives rice its longevity. Common wisdom here is as long as it doesn't get insects, get mold, or otherwise change from being dry it should be fine to cook and eat. Otherwise, it can simply sit in a bag or a storage container without apparently spoiling.

How does it do this? I'm aware that it doesn't last forever, but it sure stays edible (as long as its uncooked) for longer than I expected.
gpt
There are, broadly speaking, two ways food goes "bad"  

First is bacteria and fungal/mold growth. Both of these require water to survive. Dry rice has no water so mold and bacteria can't grow and therefore never make the food go bad. Or at least are very slowed down from making the food go bad. 

Second is a chemical reaction called rancidification which is when fats and oils chemically react with the air and become really gross. Rancid oils are usually less acutely dangerous that moldy food but it's still bad. Which is to say eating the wrong kind of mold can kill you in a day but rancid oils just make you sicker and sicker over a long period of time. 

Rice (at least white rice) is immune to both of these because it is very dry and also has no fat.