Humans only do things they think is beneficial to them. Sometimes, this can be wrong due to lack of information, misinformation, or misinterpretation of information. Stupidity occurs when one of these takes place.
Stupidity arises because humans are not perfect. They make mistakes. One of those actions will occur, and a stupid action will take place. So, stupidity is an inherent part of human nature because humans are not perfect.
There are different degrees of stupidity. For me, stupidity is more of when it should be obvious as to what the choice should be, yet mistakes occur. Stupidity also arises from miscalculated risk — a type of misinterpretation of information. Taking unnecessary risks will unnecessarily increase the probability of harm.
Stupidity not due to lack of information will become more rampant of a problem as time goes on. Humans are stopping evolution and so the genes of those with not as much brain capacity are allowed to propagate. The human interference with evolution will be discussed at length sometime this week or next week.