What's the deal with this ground wire?
Having the ground wires pulled outside the electrical box like that is one of the biggest kludge jobs I have seen in a long time. This certainly is not the way it is supposed to be done.

You did the correct thing pulling the grounds inside the box. In the box you connect them together and then pigtail that connection the that screw in the back of the box.