Custom objects and some standard objects have an associated history object that tracks changes to an object record. You can use SOQL relationship queries to traverse a history object to its parent object.
For example, the following query returns every history row for Foo__c and displays the name and custom fields of Foo:
SELECT OldValue, NewValue, Parent.Id, Parent.name, Parent.customfield__c
FROM foo__history
This example query returns every Foo object row together with the corresponding history rows in nested subqueries:
SELECT Name, customfield__c, (SELECT OldValue, NewValue FROM foo__history)
FROM foo__c