The MedicationDispense includes a reference to the 'authorizingPrescription' MedicationRequest. That's where all information about the prescription (identifier, prescriber, prescription date, prescribed drug, etc.) is captured. In FHIR we try hard to not combine information present in other resources into a referencing resource because doing so makes it hard to keep things in sync and doesn't work well for RESTful exchange. As a result, it's common to use the _include parameter when executing search to grab related resources (e.g. MedicationRequest, Organization, Medication, Practitioner, etc.) when searching against a base resource.
The 'id' is essentially the primary key for a resource as stored on a particular server. If you copy the resource onto a different server, that server will assign its own id/primary key. The 'identifier' on the other hand is a business identifier. For a dispense, this would typically be the "transaction" identifier that goes on the bottle/jar/box that uniquely identifies that particular dispense event. If the dispense information gets stored on multiple systems (e.g. it gets forwarded to the prescribing system, to a personal health record, to a centralized medication registry, etc.) it would have the same 'identifier' but would (usually) have a distinct 'id'. It's certainly possible for two closely linked systems to share the same 'id' for the equivalent records, but it requires careful coordination to avoid conflicts.
Note that the MedicationDispense.identifier is not the same as the MedicationRequest.identifier. The first is a unique identifier for a specific dispense event. The latter is a unique identifier for the overall order. There are often multiple MedicationDispense events (each with a distinct identifier) for a single MedicationRequest.