I have a question regarding map editors, like Tiled, for example. I am currently making my own map editor, and I wondered if someone could explain to me what is the purpose of layering in tiled for example. What purpose does it serve in creating a map?
Layers are needed not only the most basic use of a tile map, but also allow more artistic expression and play features. Layers define the draw order of the sprites used in your world. They're simply a way to say, "Draw sprite X after sprite Y, so that sprite X will appear on top of sprite Y". They're typically generalized into layers so you don't need to define the depth for each sprite (though you could also think of defining the depth as setting the layer). This process is referred to as the Painter's Algorithm.
The most basic use is from having the player (or any non-map item) on top of the map. The map is one layer, and the player and other items are in another layer on top of the map.
(Source for image is a nice tutorial for making a simple game)
The artistic expression and play features include allowing players to walk "behind" other objects in the world or have placeable structures/items.
Layers are not only limited to visuals. You can also have layers that define non-walkable areas, like in the example above, layer 3 could be defined as "blocking" meaning the player isn't allowed to move onto anything in that layer. This effectively creates player boundaries to help with map creation. This can expand to the physics system where you may only want some sprites to collide with sprites in their same layer. This is a simple way of disabling friendly fire for example.
Layers also allow for effects like parallax scrolling. This gives a 2D game a feeling of depth.
Having different layers makes it possible to have things that the character can walk "behind" by putting the part in front of the player. This article explains this fairly well.