In questions 1 and 2, what is being used as an interrogative pronoun, whereas in the third question it is being used as an adjective. An easy way to test this, is to try to replace "what" with "which" (not completely foolproof) - I have used "!" to indicate an ungrammatical question and "?" to indicate a slightly dubious structure.
! Do you know which the capital of Peru is?
? Do you know which the longest river in Asia is?
Do you know which language is spoken in Mexico?
You can arrange the first two questions as:
What is the capital of Peru?
What is the longest river in Asia is?
?What is language spoken in Mexico?
What/Which language is spoken in Mexico?