The GM decides when circumstances are appropriate for Hiding. When you try to hide, make a Dexterity (Stealth) check. Until you are discovered or you stop Hiding, that check’s total is contested by the Wisdom (Perception) check of any creature that actively searches for signs of your presence. When you are successfully Hiding, you are considered Hidden. See: the Conditions page.
You can’t hide from a creature that can see you clearly, and you give away your position if you make noise, such as shouting a warning or knocking over a vase.
An Invisible creature can always try to hide. Signs of its passage might still be noticed, and it does have to stay quiet.
In Combat, most creatures stay alert for signs of danger all around, so if you come out of Hiding and approach a creature, it usually sees you. However, under certain circumstances, the GM might allow you to stay hidden as you approach a creature that is distracted, allowing you to gain advantage on an Attack roll before you are seen. One of the main factors in determining whether you can find a hidden creature or object is how well you can see in an area.
When you hide, there’s a chance someone will notice you even if they aren’t searching, through Passive Perception. To determine whether such a creature notices you, the GM compares your Dexterity (Stealth) check with that creature’s passive Wisdom (Perception) score, which equals 10 + the creature’s Wisdom modifier.