I bought. 私は買った。
>>Where did you buy? どこで?
I bought at the supermarket. スーパーで買った。
>>What did you buy? 何を?
I bought what was〜 私は〜を買った。
〜の部分に「夕食に必要なもの」= Things needed for dinner が入る。
この Things 部分が what で置き換わる(この時 what=Things)ので、
I bought what was needed for dinner at the supermarked. となる。
細かい文法的な理解も良いが、感覚的なニュアンスなども捉えられないと後々応用が効かなくなる。
頑張って下さい。