What stands for the thing(s) that/which:
I didn't understand what he was saying. (the things that he was saying)
Is this what you want? (the thing that you want)
What is different from the other relative pronouns in that it does not refer back to a noun:
I wrote my essay on a photo which was taken by Robert Capa. (which refers to a photo)
That's not what we agreed on. (what does not refer to a noun)
For this reason, what can't be used instead of who, whom, whose, which or that in relative clauses:
I wrote my essay on a photo
whatwhich was taken by Robert Capa.
When in doubt, replace what with the thing(s) that/which and see if the sentence is still grammatically correct.