Is this electricity box near shower dangerous?
In general this is a bad idea in large part because metal drains cause you to be a conductor to ground and water provides various ways for the exposed wire to make contact with you. However if the junction were grounded AND the ground were protected with GFCI then this would pass as safe. Most code still doesn't allow you to have outputs or junctions near running water that are not GFCI.

If you rewire simply don't expose a junction (that includes any broken wire in the walls) near the shower. You can pass insulated wire within the shower facing walls however.

I'm going to guess this junction was on purpose to provide either power for a shower heater or for outlets but since was covered up.