I don't know how to say: why did you open this? Is it correct when I would say なぜあなたがそれは開いたの？ How can you say it differently?
Here's a suggestion:
When asking a question directly to someone, it's not necessary to say "you", in fact it is discouraged. Also, if the thing that was opened is common knowledge between you and the listener, there is no need to say "this" or "that". But if you wanted to specify you could say:
を marks the direct object (the thing that was opened) and you want to use 開｛あ｝ける instead of 開｛ひら｝いた because the former is transitive (to open a thing) while the latter is intransitive (the thing opens).