What is the potential danger of riding bicycle with cracked chainstay and how to fix it? I got a bicycle that has this big tear in the chainstay.

Is it safe for city riding? What is the potential danger?

What could someone have done to cause this kind of damage?

Most importantly what is a good procedure and material to use to fix it?

Thanks
The frame isn’t safe for using anywhere.

The potential danger is that the stay will break most likely locking up the back wheel. It might be merely inconvenient or it might be fatal taken in combination with speed or traffic. 

A possible reason for the crack is inappropriate use of the frame e.g jumps, crash damage or it might just be an old cheap Walmart frame which has fatigued. 

The frame seems to be alloy from the lack of rust in the fracture. It can’t be fixed within the scope of the bikes probable value. The presence of V brakes and a stamped metal derailleur indicates a low end bike. 

Salvage parts if you want and transfer to a not broken frame or just purchase a whole new one. The cost balance on that task will depend on whether you have bike fixing skills and tools or whether you need to take it to a bike shop.

Seriously, don’t use this bike as it is right now.