Files are containers that store data in a computer. They organize data into bytes that are interpreted based on the file type. Files can contain records of related data like payroll records for employees. Index files help provide fast random access to records in a data file by storing record numbers in a sorted array that acts as pointers to the records in the main data file. This allows algorithms like binary search to efficiently retrieve records without having to sequentially scan the entire data file.