The reason it failed is someone tryed to use just 2 X 2's instead of 2 X 4's, can not see what they used to attach it but I'd bet it was not 2-1/2 wood screws. And make sure it's screwed to the studs.
It also looks like they tryed to just tack together a frame and attached sheetrock to it to cover it up.
I would have built what amounts to two short walls out of 2 X 4's and used a piece of 3/4 cabinet grade plywood or laminated shelving board for a top. That way it's removeable and strong enought to sit on.