Mashing is done to convert the starch in the grain into fermentable sugars. When that is done, the grain is "rinsed" to get out as many as possible. That liquid is wort.
Wort is boiled to kill bacteria, isomerize the hops oils (which only happens when the wort is boiling), and to reduce the volume.