Mystery Gift is a function starting in the Pokémon Gold and Silver games. When using this, the player may get one or more gifts per day. While Gold and Silver are similar, the player will get different mystery gifts. The majority of events released through official events are made available through Wi-Fi connection, but there are some temporary events that have occurred at real-world locations.
Starting with Generation IV, this is also used as the name of a program where one can download event Pokémon off of Wi-Fi or in-store events. In Pokémon Diamond, Pearl, and Platinum, one must unlock it by talking to a man in the Jubilife TV Station, then tell him "EVERYONE HAPPY, WI-FI CONNECTION". In later games, it was already included without having to unlock it. In the Generation V games, no actions are required to obtain the Mystery Gift feature other than obtaining the Pokédex.
In the newer games such as Pokemon Sword and Shield, and Pokemon Scarlet and Violet, you can access Mystery Gift by simply opening the menu. In Sword and Shield, there is a "Mystery Gift" button in the menu where you can choose to get a Mystery Gift with methods such as via "Internet" and "Code or Password". And in Pokemon Scarlet and Violet, you can choose the "Poke Portal" in the menu, and choose "Mystery Gift", where you have the same options as you do in Sword and Shield.