This game has several functions to determine when and where monsters will spawn:
The only difficulty in which monsters will not spawn is "Peaceful". Anything higher will cause monsters to spawn including "Easy". If you return to Peaceful, any mobs that have spawned, will despawn.
There are two game modes: Creative and Survival. While this does not determine whether or not monsters will spawn, it will determine their aggressiveness toward the player. In Creative monsters will not be hostile, however they will still spawn and wander around aimlessly until attacked directly by the player. In Survival monsters will be hostile toward you once they enter a certain radius. Note: I'm not sure if this is a feature in pocket edition.
Once it gets dark enough monsters will begin to spawn. This is true for nigh and day, in forests, caves, or unlit structures that you have made. Placing torches around the areas will stop this from happening.
The distance in this game is measured by what is defined as "Chunks" that are loaded and unloaded when a player moves around the map. When a chunk is unloaded, any hostile entities (or mobs) will despawn after a certain time.