I'll preface by saying that I have never set up a grinder in the dungeon. I just ran around killing things with battle potions and water candles for a couple hours to get all the gear I needed.
What preparations do I need to make to make a safe dungeon grinder?
I am not actually sure that you can. Quite a few enemies in the dungeon can pass through walls. Several can teleport. There are also many attacks that can pass through walls, including the Paladin's hammer and The Ragged Caster's Lost Soul Bolts. The Ragged Casters in particular can hide just off screen and shoot directly at you.
How deeply should it be built?
I can't find anything that would support the spawn rate being higher at lower levels. You can use water candles and battle potions in the Dungeon, though.
According to the Wiki, the Dungeon has 2 different spawn rates depending on the layer you are in:
+-----------------------+------+-------------+
| Biome | Rate | Max Enemies |
+-----------------------+------+-------------+
| Dungeon (dirt layer) | 97 | 15 |
| Dungeon (stone layer) | 86 | 15 |
+-----------------------+------+-------------+
What that means is that every 60th of a second, there is a 1 in Rate
chance of a monster spawning. As you can see, the difference in the Dungeon is pretty negligible. Other factors should probably take priority, but technically building it in the cavern layer is slightly better. You will have to figure out the cavern layer depth outside of the dungeon by taking a GPS and finding where the background changes. You can get a guide from the depths listed on the wiki page:
+----------+-----------------+---------------------+-----------------+
| Map Size | Min Start Depth | Average Start Depth | Max Start Depth |
+----------+-----------------+---------------------+-----------------+
| Small | 120 ft | 480 ft | 840 ft |
| Medium | 180 ft | 720 ft | 1260 ft |
| Large | 240 ft | 960 ft | 1680 ft |
+----------+-----------------+---------------------+-----------------+
For more information, see the page on Monster Spawning.
Preferable background?
That depends on what items you want to get. As you said, some monsters only spawn on specific backgrounds. For those purposes, you could almost consider the dungeon 3 different biomes-- one for each wall type. It might make sense to set up a farm on each background. You might also try to set up your farm on an intersection between the 3 backgrounds so you can get spawns from all of them. I should note that the backgrounds behind the foreground blocks do not necessarily match the adjacent walls. You might be able to get other enemies to spawn in an area by mining away some of the foreground blocks.
I have a huge amount of dart traps, lava and some spear and spiky ball traps I got from the entrance of the Lihzahrd Temple (they generated outside of the door).
The hard mode monsters in the dungeon are actually really powerful. I would actually recommend going to the lihzahrd temple first to get some of the traps there so that you can set this up with traps that will kill monsters in a reasonable amount of time. You can go in there as soon as you kill Plantera. You don't need anything special to get the traps and you won't need to beat the golem if you don't want to.