Why do we have a booking code and a ticket number?
Part of it is a hold-over to historical systems (where airlines ran their own booking systems). Now that most airlines use a global system like Amadeus this is less of an issue.

The ticket number (PNR) and booking number (record locator) do have slightly different purposes though. The former contains the details needed for the actual flight (your name, contacts details, flight numbers, etc) while the record locator can also contain other information not directly related to the flight.
In short: The record locator contains a reference to the PNR but can also contain additional information that is not contained in the PNR.